
> ##Replication File for "Authoritarian Audiences, Rhetoric, and Propaganda in International Crises: Evidence from China"
> ##Authors: Jessica Chen Weiss and Allan Dafoe
> 
> ##Replication Hypothetical History
> 
> 
> #Packages
> library(ggplot2)

> require(reshape2)

> require(coefplot)

> library(robustbase)

> setwd("~/Dropbox/Dafoe-Weiss-Empirics/18-04-12-ISQ-Raluca/Code/Replication File ISQ/")

> d <- read.csv("./MASTER CODE/150922Hypotheticals.csv")

> #This dataset has a column a.pcono in which we had translated the country entered by the respondent in response to question pcono. 
> d.merge <- read.csv("./MASTER CODE/150922Hypotheticals-c.csv")

> #Drop first row
> orig.var.names <- d[1,]

> d <- d[-1,]

> #Drop first row
> orig.var.names.merge <- d.merge[1,]

> d.merge <- d.merge[-1,]

> d.merge2 <- d.merge[,c("V1", "V6", "a.pcono")]

> #Merging in a.pcono
> d2 <- merge(d,d.merge2)

> d <- d2

> rm("d.merge", "d.merge2", "d2")

> #### Start and End Time
> d$start.time <- strptime(d$V8, "%Y-%m-%d %H:%M:%S")

> d$end.time <- strptime(d$V9, "%Y-%m-%d %H:%M:%S")

> #Drop those starting before Oct 15 2015 11pm
> d <- d[d$start.time>"2015-10-14 23:00:00",]

> ##Last start.time
> d$start.time[length(d[,1])]
[1] "2015-11-01 06:27:23 GMT"

> #Drop those who came in over the quota. All data is missing
> d <- d[d$quota!="overall",]

> ### Indicator for Partner
> #"Yes, those with an "rid" and "RISN" value are from the original panel (respondents should have both variables), and those with a "gid" and "sname" value are from the additional panel we brought on yesterday."
> d$partner <- rep(NA, length(d[,1]))

> d$partner[d$RISN=="" & d$gid!=""] <- "B"

> d$partner[d$RISN!="" & d$gid==""] <- "A"

> d$partner <- as.factor(d$partner)

> #Dropping those who didn't come from either partner
> which(is.na(d$partner)==TRUE)
 [1]   55   61   91  163  164  199  300  321  328  457  674  845  858  928  930  957 1019 1152 1181 1261 1322 1344 1367 1443
[25] 1450 1467 1483 1563 1607 1754 1845 1950 2061 2270 2281 2396 2433 2555 2719 2725 2759 2898 2982 3055 3176 3194 3234

> d<-d[!is.na(d$partner),]

> #### Attention Checks ####
> #Number of respondents who pass all attention checks.(only those who pass the first get to ctri)
> r <- d$term=="" & d$quota==""

> r2 <- (d$ctri== 2 | d$ctri==1) 

> table(r,r2)
       r2
r       FALSE TRUE
  FALSE   693  186
  TRUE    305 2057

> rc <- r==TRUE & r2==TRUE

> sum(rc)
[1] 2057

> d$att <- rep(0, length(d[,1]))

> d$att[rc] <- 1

> #Measure time taken
> d$time.taken <- difftime(d$end.time, d$start.time, units='mins')

> #### Creating Pre-Scenario Question Variables ####
> ## Pre Approval
> #Combining approval together
> 
> var <- d$as0

> var.r <- d$as0r

> out <- rep(NA, length(var))

> order.r <- rep(NA, length(var))

> r <- !is.na(as.numeric(as.character(var)))

> out[r] <- as.numeric(as.character(var))[r]

> order.r[r] <- 0

> r <- !is.na(as.numeric(as.character(var.r)))

> out[r] <- as.numeric(as.character(var.r))[r]

> order.r[r] <- 1

> d$asc0 <- out

> d$asc0
   [1] NA  4 NA NA NA  3  4 NA  4  4 NA  3  4  4  4  5 NA  4  4 NA NA  3  3  3  2  3  4  4 NA NA  4  4  4  4  1  4  4  4  2  1
  [41]  4  5  3  5 NA  3  5  3  4  3  3  4 NA  4  3 NA NA  2  3  4  4 NA  4  2  5  1 NA  3  3 NA  3 NA  3  3  4  5 NA  3 NA  5
  [81] NA NA  5  3  5  5  4 NA  3 NA  4  4  4 NA  5 NA  5  3  4  3  4  4  2 NA  4  5  4  5 NA  4 NA  4  4 NA  4  5 NA  4  4  4
 [121] NA  4  4  4  3 NA  3  4 NA  4  4  4  4  2  4  3  5  2  5  5  5  5  3 NA NA  4 NA NA  3  4  4 NA NA  3  4  3  5  4  4  4
 [161]  2  4  4  2  4  5  4  1  4 NA  4  4  4  4  5 NA  5  5 NA NA  4 NA  4 NA  5 NA  1 NA  1  5  5  4  5  4 NA  3  3  3 NA  5
 [201]  3  4  5  3  4  2  4 NA  4 NA NA NA  2  4 NA  4  5 NA  4  5  3  5  3 NA  5 NA  5  3 NA NA  4  3  2  3  5 NA  5  3  4  4
 [241]  4  3  4 NA NA  4  4 NA  4  3  5  4 NA NA  4  5  3  3  5  3  4  2  4 NA NA NA NA  4  3  5  4 NA NA  4  4 NA  3  5  4 NA
 [281]  4  3 NA  4  4  3  4  4 NA NA  3  3 NA  4  3  4  4  2  3  3  3 NA  4 NA  4 NA  4  5  3  1  4 NA  5  4  5  4  4 NA  4  1
 [321]  3  5  3  5 NA  1  5 NA  5  2 NA  5  4  2  5  3  5  3  4 NA NA  3 NA  4  1 NA  1  4  5 NA  4  3 NA  4  4  4 NA  4  4 NA
 [361]  4  4  4  5 NA  2  4  4  5  4  3  4 NA  4  5  3  4  4  4  5  4  5  5  5 NA  4  4  3  3  5  2 NA  4  4 NA  4  4  5 NA  5
 [401]  4 NA  4  4  4 NA  3 NA  4  5  4 NA NA NA  3 NA  3 NA  5 NA  4  4  4  4 NA NA  3 NA  4  4  4  5  4 NA  4  3 NA  3  3  3
 [441]  4  2  3  4 NA  5  4  5  4 NA  5  5  4  4  4  4  3  4  4  4  4  4  4  4 NA  3  3  4 NA NA  4  5  3 NA  3  5  5  2 NA  3
 [481] NA  5 NA NA NA  1 NA  4 NA NA  4  2  4 NA  4 NA  2  3  5  2 NA  5  5  4  3  3  5 NA  3  3 NA  4  4 NA  3  1  5  3  5  4
 [521] NA NA  5  4  4  4 NA NA NA  5  3  4 NA  3  4 NA  4  4  2  4  4  4  4  3  3  3  4  3  4  4  5 NA  5  4  4  4 NA  4  5  3
 [561] NA  4  4  5  5  5  4 NA NA  4  3  3 NA  4  3 NA  4 NA  4  4  3  4 NA  4  4  2 NA  4  3  4  4  4  3 NA  5  5 NA  4 NA  4
 [601]  5  4 NA  4 NA  4  5  4 NA NA  4 NA  1  3 NA NA  4  3 NA  4  4  4 NA  4  5 NA  4 NA  3  4  4  5  3  3  4  4 NA NA NA NA
 [641]  3 NA  4  2  4  3  5  4  5  4  4 NA  3  4  4  5  4 NA  3  1  5  5  5  5  5  1  5 NA  4 NA NA  5  5 NA NA  4 NA  4 NA  4
 [681]  4  4  4  5  2  4 NA  5 NA  5 NA  5  3  4 NA  1  3 NA  4  5  3  3 NA  5 NA  5  5  2 NA  4  4  3 NA  3  3  4  4  4  2  5
 [721] NA  3  4  3  3 NA  4  4  4  3  3 NA NA  4 NA  3  5  4  3  5  3 NA  4  3  5  3 NA NA  2  1  2 NA NA  4  5  4  3  4 NA  4
 [761]  2  3  5  3  3  5  3  3  3 NA NA  3  4  5 NA  5  4  5  3  3  3  4  3  4  4  4  4  5  5  4  5  3  4  4  3  4  5  3  4  3
 [801] NA  5 NA  4  4  5  5 NA  3  2  4 NA  3  5 NA  5  4  3  4  4  4  3  4 NA  5 NA NA  3  4  3 NA  4 NA  3  4  4  4 NA  3 NA
 [841] NA NA  2  4  4  4  4 NA  4  4  5  5 NA NA  4  4  4  3  4  4  5  5  4  4  4  4  4  5 NA  5 NA  4  2 NA  3 NA NA  3 NA  5
 [881]  4  5  3 NA  4  4 NA  3 NA  5 NA NA NA  4  4 NA  3  3  4 NA  4  5 NA  1 NA  3  4 NA  5  4  3 NA NA NA  4  3  5  3  4  5
 [921]  5  4 NA  3  4 NA  4  4  5  3  5  5  4  3  4  3  4 NA  4  2 NA NA  5 NA  4 NA  4 NA NA  4  2 NA  5 NA  5 NA  3 NA  4 NA
 [961]  5 NA  4 NA NA  4  4  2  5  4  3  4 NA  4  4  4  4 NA  5  5  4 NA  5  3  4  3  2  3  4  3 NA  4  4  4  4 NA NA  1 NA  4
 [ reached getOption("max.print") -- omitted 2241 entries ]

> d$asc0.or <- order.r

> var <- d$na1_1

> out <- rep(NA, length(var))

> r <- !is.na(as.numeric(as.character(var)))

> out[r] <- as.numeric(as.character(var))[r]

> d$na1.v <- out

> d$na1.v
   [1] NA  9 NA NA NA 10  9 NA  5 10 NA  1  7  8  8  9 NA  8 10 NA NA  9  8 10  2  5 NA  8 NA NA  9  5  7 10 NA  8  9 10  5  9
  [41]  7  9  8 10 NA  1 10  4  6  8  8  9 NA  5  9 NA NA  9  8  4  9 NA  6  8 10  6 NA  8  3 NA 10 NA  5  7  7  9 NA  8 NA  5
  [81] NA NA  9  7 10 10  9 NA 10 NA  9  9 10 NA  7 NA  8  7 10  6  8  8  9 NA  9 10 10 10 NA 10 NA  9  9 NA  8  1 NA  8  9 10
 [121] NA 10 10  9  6 NA  8  7 NA  9  9 NA  7  2 10  4  8  7 10 10 10 10  5 NA NA  3 NA NA  6  7 10 NA NA  7  6  3 10 10 10  8
 [161]  6  8  7  9  7 10  8 NA  6 NA  7 10  9 10 10 NA 10  8 NA NA  9 NA 10 NA  5 NA  9 NA  0 10  8  9  9  6 NA  6 NA  4 NA 10
 [201]  6  5  9 10  8 10  9 NA  9 NA NA NA  1 NA NA  9  8 NA  9 10  3 10  8 NA 10 NA 10  5 NA NA  9 10  9 10 10 NA 10  6  9  5
 [241]  8  8  3 NA NA 10  9 NA  7  5  8  8 NA NA  8 10  3  7  5  9 10  8  5 NA NA NA NA  9  6 10 10 NA NA  7  8 NA 10 10  9 NA
 [281] 10 10 NA  9 10  6 10  7 NA NA  6 10 NA 10  8  6  9 10  8 10  4 NA  7 NA  6 NA  7 NA  6  0 10 NA 10  5 10  9  9 NA  8  5
 [321]  4 10  8  9 NA  3  8 NA  9  8 NA NA  8  8 10 10 10  9 10 NA NA  8 NA  9  0 NA  5  8 10 NA 10  8 NA  8 10  9 NA NA  8 NA
 [361]  8  8  8 10 NA 10 10  8 10  9 10  9 NA  9 10  5  8  7  8  7  7 10 10  9 NA  6 10  6  4  9 10 NA  7 10 NA  9  7 10 NA  8
 [401]  8 NA  8 10  6 NA 10 NA  6  9  7 NA NA NA  8 NA  9 NA  8 NA 10 10 10  7 NA NA 10 NA  8 10  9  9  7 NA  7 NA NA  4  9 10
 [441]  7  9  7  9 NA 10  9  9  6 NA 10  9  7  8 10 10  5  8  8  8 10  8 10  8 NA  8  9 10 NA NA  6 10  5 NA  3 10 10  5 NA  9
 [481] NA  5 NA NA NA  2 NA  9 NA NA  9  5  8 NA NA NA 10 10 10  6 NA  9 10  8  5  8 10 NA  6 10 NA  8  8 NA  5  7 10  5  5  9
 [521] NA NA 10  9  9  9 NA NA NA 10  4  9 NA 10  9 NA  9  4  9 10  8  9 10  7 10  5  8 10  8  7  9 NA 10 10 10  7 NA 10 10  7
 [561] NA  5  8  9 10  8  8 NA NA  9  5 10 NA  8  6 NA  7 NA  6  7 10  7 NA  9  4 10 NA 10  6 10  8  8  7 NA 10 10 NA  9 NA  8
 [601]  8  7 NA 10 NA  4 10  5 NA NA  7 NA 10  9 NA NA  7 10 NA 10 10  4 NA  5  9 NA 10 NA  6  8  6  9  5  7  7  5 NA NA NA NA
 [641] 10 NA  5  8  6  8  7  8  9  8  8 NA  5 10  5  8  5 NA  8  9  9 10 NA  5  5  8  9 NA  9 NA NA 10  2 NA NA  7 NA  7 NA  7
 [681] 10  8  8 10  9  9 NA 10 NA 10 NA 10 10 10 NA 10  8 NA  7  7  9  7 NA  8 NA 10 10  5 NA  6  7  7 NA  6 10  8  9  6 10 10
 [721] NA  7  8  7  9 NA  7  7  7  6  5 NA NA  3 NA  6 10  5  5 10  7 NA 10  7 10  8 NA NA  9 10  7 NA NA  8 10  8  8  9 NA  9
 [761]  9  5  6  8  8 10  8 10  7 NA NA 10 10 10 NA  6  9  8  8  6  3  7  7  8  9  6  8 10  9  9  8  1  5  6  8  7 10  6  8  9
 [801] NA  9 NA  8  9  8  9 NA  6  9  6 NA  9 10 NA  9  8  5  6  7  9  4 10 NA  8 NA NA  7  7  5 NA 10 NA  5  9  9  5 NA  7 NA
 [841] NA NA 10  8 10  8  9 NA  9  7  8 10 NA NA  6  9 10  3 10  7 10 NA  8  8  9 10  9 10 NA  6 NA  8  1 NA  5 NA NA  8 NA 10
 [881]  9  9  8 NA  8  8 NA  9 NA  8 NA NA NA  9 10 NA  7  3 10 NA  8 10 NA  8 NA  9  5 NA 10  6  6 NA NA NA 10  5 10  8 10 10
 [921] 10  6 NA  8  4 NA  8  8 10  9 10  7  6  5 10 NA  4 NA 10  3 NA NA  7 NA  3 NA  7 NA NA  2  9 NA  7 NA  6 NA  6 NA  7 NA
 [961]  7 NA 10 NA NA  9 10  8  6  9  7  8 NA  6  9  8  7 NA  7  9 10 NA 10  8  7  9  5  9  9  5 NA  6 10 10  8 NA NA  2 NA 10
 [ reached getOption("max.print") -- omitted 2241 entries ]

> var <- d$na2

> out <- rep(NA, length(var))

> r <- !is.na(as.numeric(as.character(var)))

> out[r] <- as.numeric(as.character(var))[r]

> d$na2.v <- out

> #Recording variable so that about right is in the middle at 2, and don't know and refuse to answer are also set to 2
> d$na2.v.dn <- rep(0, length(d[,1]))

> d$na2.v.dn[d$na2.v==8 | d$na2.v==9] <- 1

> d$na2.v.dn[d$na2.v==1 | d$na2.v==2 | d$na2.v==3] <- 0

> d$na2.v[d$na2.v==3] <- -99

> d$na2.v[d$na2.v==2] <- 3

> d$na2.v[d$na2.v==-99] <- 2

> d$na2.v[d$na2.v==8] <- 2

> d$na2.v[d$na2.v==9] <- 2

> var <- d$na3

> out <- rep(NA, length(var))

> r <- !is.na(as.numeric(as.character(var)))

> out[r] <- as.numeric(as.character(var))[r]

> d$na3.v <- out

> d$na3.v
   [1] NA  4 NA NA NA  2  2 NA  3  4 NA  1  3  4  3  3 NA  2  4 NA NA  3  4  2  1  3 NA  3 NA NA  4  3  2  4 NA  3  2  2  1  4
  [41]  3  4  3  3 NA  2  4  3  3  2  2  3 NA  3  3 NA NA  2  3  3  2 NA  4  3  3  4 NA  4  5 NA  2 NA  2  4  3  3 NA  4 NA  4
  [81] NA NA  3  4  4  3  3 NA  4 NA  3  4  2 NA  3 NA  2  3  4  3  3  3  4 NA  3  2  3  4 NA  3 NA  3  3 NA  4  2 NA  3  3  2
 [121] NA  4  3  4  3 NA  4  3 NA  3  4 NA  3  4  4  2  1  3  8  5  3  3  8 NA NA  5 NA NA  3  2  4 NA NA  3  4  3  5  4  4  3
 [161]  1  4  3  4  2  4  3 NA  5 NA  2  3  3  4  5 NA  5  3 NA NA  3 NA  2 NA  2 NA  3 NA  1  2  2  5  4  5 NA  8 NA  3 NA  4
 [201]  3  8  3  1  3  4  3 NA  4 NA NA NA  3 NA NA  3  2 NA  3  4  4  5  4 NA  4 NA  1  4 NA NA  3  3  2  2  4 NA  1  3  2  4
 [241]  4  4  2 NA NA  4  4 NA  3  3  2  3 NA NA  2  9  3  3  2  5  3  4  3 NA NA NA NA  3  3  3  4 NA NA  4  3 NA  3  5  2 NA
 [281]  5  4 NA  4  3  3  3  4 NA NA  3  3 NA  4  2  4  3  4  5  4  3 NA  2 NA  4 NA  3 NA  4  4  2 NA  3  2  3  4  3 NA  4  4
 [321]  4  3  2  4 NA  3  4 NA  2  3 NA NA  4  4  3  4  4  4  4 NA NA  2 NA  4  5 NA  9  3  3 NA  4  3 NA  4  4  3 NA NA  3 NA
 [361]  4  3  2  4 NA  1  4  4  5  4  3  3 NA  4  3  8  3  4  4  1  4  5  3  5 NA  3  9  1  4  2  4 NA  3  3 NA  3  3  3 NA  4
 [401]  4 NA  5  4  3 NA  4 NA  4  4  2 NA NA NA  4 NA  3 NA  2 NA  2  4  3  4 NA NA  1 NA  3  5  4  2  3 NA  3 NA NA  2  4  8
 [441]  4  4  3  2 NA  5  3  4  3 NA  5  4  4  3  5  4  2  4  3  2  2  4  4  4 NA  2  3  3 NA NA  3  1  4 NA  4  1  4  2 NA  4
 [481] NA  3 NA NA NA  5 NA  4 NA NA  4  1  3 NA NA NA  4  3  3  5 NA  2  4  2  8  3  2 NA  2  3 NA  3  4 NA  9  3  3  3  2  3
 [521] NA NA  3  2  2  4 NA NA NA  4  2  3 NA  2  4 NA  3  3  1  1  3  4  3  3  4  2  3  2  4  4  4 NA  4  4  3  3 NA  4  2  3
 [561] NA  2  2  4  4  2  2 NA NA  4  3  3 NA  4  8 NA  4 NA  3  3  9  3 NA  3  3  5 NA  3  2  5  4  3  3 NA  3  2 NA  2 NA  3
 [601]  4  3 NA  4 NA  4  4  3 NA NA  3 NA  3  3 NA NA  1  3 NA  2  3  5 NA  3  4 NA  4 NA  4  2  3  4  2  3  2  4 NA NA NA NA
 [641]  1 NA  2  4  2  3  2  4  4  4  4 NA  4  3  3  3  2 NA  4  5  5  5 NA  2  5  1  3 NA  2 NA NA  2  2 NA NA  3 NA  3 NA  4
 [681]  4  4  3  5  4  5 NA  3 NA  9 NA  5  1  4 NA  2  3 NA  3  5  4  2 NA  3 NA  4  3  3 NA  3  8  3 NA  3  3  3  4  4  4  4
 [721] NA  3  4  1  3 NA  3  3  3  3  3 NA NA  2 NA  3  3  4  3  4  3 NA  4  3  3  3 NA NA  3  4  5 NA NA  3  5  3  3  2 NA  2
 [761]  4  3  3  4  4  4  3  4  4 NA NA  2  2  4 NA  4  4  3  3  5  1  3  4  4  4  3  3  4  4  4  2  1  8  4  3  4  3  3  3  3
 [801] NA  4 NA  4  3  4  3 NA  2  1  4 NA  4  4 NA  2  3  3  2  2  3  4  2 NA  3 NA NA  4  3  4 NA  4 NA  3  4  5  4 NA  3 NA
 [841] NA NA  3  2  3  2  4 NA  3  3  5  3 NA NA  4  3  1  3  4  4  1 NA  4  4  3  4  3  5 NA  1 NA  4  4 NA  3 NA NA  3 NA  3
 [881]  4  3  3 NA  2  5 NA  3 NA  2 NA NA NA  2  4 NA  3  4  2 NA  3  4 NA  1 NA  4  3 NA  4  3  3 NA NA NA  2  8  4  4  2  4
 [921]  3  4 NA  2  3 NA  3  2  8  4  4  3  3  2  2 NA  4 NA  3  4 NA NA  2 NA  4 NA  2 NA NA  4  1 NA  4 NA  3 NA  3 NA  3 NA
 [961]  4 NA  4 NA NA  2  4  4  2  4  4  1 NA  4  4  4  5 NA  2  3  4 NA  4  8  2  4  4  2  3  5 NA  3  5  3  4 NA NA  8 NA  3
 [ reached getOption("max.print") -- omitted 2241 entries ]

> d$na3.v.dn <- rep(0, length(d[,1]))

> d$na3.v.dn[d$na3.v==8 | d$na3.v==9] <- 1

> d$na3.v.dn[d$na3.v!=8 & d$na3.v!=9] <- 0

> #moving 8 don't know; 9 refuse to answer to 3 moderate
> d$na3.v[d$na3.v==8] <- 3

> d$na3.v[d$na3.v==9] <- 3

> d$pre.questions <- rep(NA, length(d$na3.v))

> d$pre.questions[is.na(d$na3.v)] <- 0

> d$pre.questions[!is.na(d$na3.v)] <- 1

> plot(density(d$asc0[d$pre.questions==1]))

> plot(density(d$na2.v[d$pre.questions==1]))

> plot(density(d$na3.v[d$pre.questions==1]))

> hist(d$asc0[d$pre.questions==1], main="Approval", breaks=seq(0.5, 5.5, 1))

> #### Creating Main Variables ####
> 
> #### Creating Approval and Resolve Variables ####
> #Measure Approval as1 as1r
> #Combining approval measures
> 
> 
> #Combining approval together
> var <- d$as1

> var.r <- d$as1r

> out <- rep(NA, length(var))

> order.r <- rep(NA, length(var))

> r <- !is.na(as.numeric(as.character(var)))

> out[r] <- as.numeric(as.character(var))[r]

> order.r[r] <- 0

> r <- !is.na(as.numeric(as.character(var.r)))

> out[r] <- as.numeric(as.character(var.r))[r]

> order.r[r] <- 1

> d$asc <- out

> d$asc
   [1]  3  4  3 NA  1  1  2  3  2  2  2  3  3  2  2  5 NA  2  3 NA  3  2  2  1  3  3 NA  2  3  3  3  3  2  1 NA  3  4  4  2  1
  [41]  3  4  3  3  3  3  5  2  3  3  4  4 NA  4  2  4  3  2  3  2  2  1  4  2  5  2  4  2  3  5  3 NA  2  3  4  4  4  3  2  5
  [81]  1 NA  2  2  5  5  3  4  4  4  3  2  2 NA  4  4  3  2  2  3  4  3  1  3  4  1  2  4  3  3  5  4  2  2  4  4  4  3  4  2
 [121]  4  1  2  4  3  3  3  2  3  3  4 NA NA  3  4  3  5  2  2  1  4  4  3  2 NA  2  5  3  3  3  4  4  3  3  4  3  4  4  2  3
 [161]  2  5  2  1  3  4  3 NA  4  3  4  4  3  4  5  1  5  2  4 NA  2  3  4  1  5  4  1  3  1  4  4  4  5  4  4  3 NA  3  3  5
 [201]  4  1  5  2  2  3  5  4  4  5  2  2  2 NA  4  1  1 NA  4  1  3  5  3  1  2  3  1  3  3 NA  3  3  1  1  4  3  1  3  1  2
 [241]  3  3  1  4  3  2  4  4  1  3  2  4  1  1  3  3  3  4  4  3  4  3  2 NA  2  3  1  2  2  5  3  5  2  3  2 NA  2  5  2  4
 [281]  2  1  2  4  4  3  4  4  2  5  4  5  4  2  3  4  3  1  2  2 NA  3  2  5  3  1  3 NA  3  3  2 NA  5  2  4  3  2  1  3  3
 [321]  3  3  3  3  2  5  4 NA  4  2  2 NA  2  4  1  1  5  3  3  4 NA  3  5  2  1 NA  5  3  4 NA  4  2  2  3  5  2  3 NA  2  4
 [361]  2  4  2  3  5  1  2  3  4  5  4  3  5  4  2  3  4  2  3  1  2  5  4  4 NA  2  2  2  4  2  1  3  3  2  4  3  3  3  4  3
 [401]  2  4  2  1  4  3  2  2  3 NA  2  4  3  5  4  2  4  2  4 NA  3  2  5  2  2  1  3 NA  3  4  1  4  4  1  4 NA  2  4  1  3
 [441]  4  3  4  2  4  4  4  1  4  5  5  2  1  4  1  3  2  4  2  3  4  2  4  4  2  2  1  3  5 NA  3  1  3  3  4  5  3  4  4  2
 [481]  2  5 NA  2  5  2  3  3  2  2  2  2  4  3 NA  2  1  1  4  1  1  4  4  3  3  3  1  1  1  1 NA  4  4  1  3  1  4  3  3  1
 [521]  4  2  5  4  3  3  3  3  3  5  2  2 NA  2  2  3  3  4  1  1  3  2  4  3  2  3  3  4  3  4  2  2 NA  4  2  4  4  4  4  2
 [561] NA  4  4  3  4  4  4  2 NA  4  2  1  4  2  3  2  2 NA  2  3  3  4  5  2  4  4  4  2  3  2  3  1  2  4  4  4  4  2  3  2
 [601]  4 NA  1  2  2  4  4  3 NA  4  4  2  2  2  3  2  4  3  3  2  2  3  3  3  3  1  3  4  3  2  3  5  3  2  3  4  4 NA  5 NA
 [641]  4  4  4  2  4  3  5  3  5  4  3  2  3  5  4  3  5 NA  2  2  1  4 NA  3  3  1  3  3  2 NA  5  2  2 NA  3  4  3  4  3  3
 [681]  3  2  4  4  3  5 NA  5  4  5  3  2  2  1  1  1  3  1  4  1  2  3 NA  2  4  2  4  3 NA  3  4  3  3  2  3  4  3  3  2  4
 [721] NA  3  3  4  3  2  3  3  4 NA  2 NA NA  4  3  2  3  3  3  2  2  3  4  3  1  3  1  3  1  1  2  4  1  3  5  4  3  4  4  1
 [761]  2  2  3  2 NA  3  2  4  3  2  3  3  2  2  2  4  4  4  3  2  3  4  3  4  4  2  4  4  2  1  5  3  3  2  4  3  2  2  2  2
 [801]  3  2  3  4  4  4  2  3  3  1  4  2  4  2  3  4  2  2  3  3  2  3  2 NA  5  3 NA  3  3  3  3  2  2  3  1  4  3  4  3  5
 [841]  1  3  2  3  4  4  2  4  4  4  5  5 NA NA  3  1  5  2  1  1  5 NA  4  4  4  4  4  2 NA NA  4  2  3  3 NA  4  1  2  1  4
 [881]  1  4  2  3  3  4 NA  3  3  4  1 NA NA  2  2  2  3  3  2  2  1  4  5  1  3  1  3  3  3  3  3  4  5  1  3  3  4  3  2  4
 [921]  2  4 NA  2  4  4  4  4  3  2  3  2  3  3  4 NA  3  2  2  3  1  4  2  3  2 NA  2  4  4  4  2 NA  3  5  5  3  3  2  2  5
 [961]  5 NA  4 NA  4  2  4  1  3  2  2  4  1  3  3  4  4  2  3  3  3  4  3  3  4  2  2  3  3  3 NA  4  1  3  2  2  4  1  1  4
 [ reached getOption("max.print") -- omitted 2241 entries ]

> #asc.or: asc is in order reversed
> d$asc.or <- order.r

> #Order effects for approval
> d$as1.n <- as.numeric(as.character(d$as1))

> d$as1.n2 <- as.numeric(as.character(d$as1r))

> #Measure Resolve
> #Combining resolve together
> var <- d$ra1_1

> var.r <- d$ra1r_2

> out <- rep(NA, length(var))

> order.r <- rep(NA, length(var))

> r <- !is.na(as.numeric(as.character(var)))

> out[r] <- as.numeric(as.character(var))[r]

> order.r[r] <- 0

> r <- !is.na(as.numeric(as.character(var.r)))

> out[r] <- as.numeric(as.character(var.r))[r]

> order.r[r] <- 1

> d$rac <- out

> d$rac.or <- order.r

> #Note that anchoring doesn't seem to affect resolve answer
> d$ra1.n <- as.numeric(as.character(d$ra1_1))

> d$ra1.n2 <- as.numeric(as.character(d$ra1r_2))

> r <- !is.na(d$rac)

> plot(density(d$rac[r]))

> # Resolve 2
> d$ra3c <- as.numeric(as.character(d$ra3))

> #Correlation between Resolve and Resolve2 greater for Hyp than for Real. Regression coefficient twice the size
> summary(lm(d$rac ~ d$ra3c))

Call:
lm(formula = d$rac ~ d$ra3c)

Residuals:
    Min      1Q  Median      3Q     Max 
-65.280 -13.442   0.558  15.720  50.976 

Coefficients:
            Estimate Std. Error t value            Pr(>|t|)    
(Intercept)  43.6050     1.9778   22.05 <0.0000000000000002 ***
d$ra3c        5.4187     0.6413    8.45 <0.0000000000000002 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 22.32 on 2155 degrees of freedom
  (1084 observations deleted due to missingness)
Multiple R-squared:  0.03207,	Adjusted R-squared:  0.03162 
F-statistic:  71.4 on 1 and 2155 DF,  p-value: < 0.00000000000000022


> #Resolve2 as a dichotomous variable (4 or not 4) (more motivated by Real results)
> d$ra3c.d <- d$ra3c

> d$ra3c.d[d$ra3c==4] <- 1

> d$ra3c.d[d$ra3c<4] <- 0

> #### Creating background variables ####
> start.num <- which(names(d)=="X00000")

> colorder<-seq(from=start.num,to=(start.num+5*31),by=5)

> names(d)[colorder]
 [1] "X00000" "X00001" "X00010" "X00011" "X00100" "X00101" "X00110" "X00111" "X01000" "X01001" "X01010" "X01011" "X01100"
[14] "X01101" "X01110" "X01111" "X10000" "X10001" "X10010" "X10011" "X10100" "X10101" "X10110" "X10111" "X11000" "X11001"
[27] "X11010" "X11011" "X11100" "X11101" "X11110" "X11111"

> length(colorder)
[1] 32

> newd<-d[,colorder]

> len <- length(d[,2]) #used to be 1078

> counter<-matrix(0,nrow=len,ncol=32)

> newd2 <- as.matrix(sapply(newd, as.character))

> newd3 <- newd2

> newd3[newd2==""] <- "0"

> newd4 <- matrix(as.numeric(unlist(newd3)),nrow=nrow(newd3))

> ## Creating variables
> var <- rep(NA, length(d[,1]))

> names.v <- names(d)[colorder]

> #The following code finds the columns in newd that contain the relevant 1 turned on, and then evaluates whether a given row has any of those turned on
> d$authoritarian <- rowSums(newd4[,grep("X1", names.v)])

> names.v[grep("X[01]1", names.v)]
 [1] "X01000" "X01001" "X01010" "X01011" "X01100" "X01101" "X01110" "X01111" "X11000" "X11001" "X11010" "X11011" "X11100"
[14] "X11101" "X11110" "X11111"

> d$ally <- rowSums(newd4[,grep("X[01]1", names.v)])

> names.v[grep("X[01][01]1", names.v)]
 [1] "X00100" "X00101" "X00110" "X00111" "X01100" "X01101" "X01110" "X01111" "X10100" "X10101" "X10110" "X10111" "X11100"
[14] "X11101" "X11110" "X11111"

> d$capabilities <- rowSums(newd4[,grep("X[01][01]1", names.v)])

> names.v[grep("X[01][01][01]1", names.v)]
 [1] "X00010" "X00011" "X00110" "X00111" "X01010" "X01011" "X01110" "X01111" "X10010" "X10011" "X10110" "X10111" "X11010"
[14] "X11011" "X11110" "X11111"

> d$salience <- rowSums(newd4[,grep("X[01][01][01]1", names.v)])

> names.v[grep("X[01][01][01][01]1", names.v)]
 [1] "X00001" "X00011" "X00101" "X00111" "X01001" "X01011" "X01101" "X01111" "X10001" "X10011" "X10101" "X10111" "X11001"
[14] "X11011" "X11101" "X11111"

> d$his <- rowSums(newd4[,grep("X[01][01][01][01]1", names.v)])

> #### Create treatment variables ####
> #pro is provocation
> #prot is protests
> #com is commitment
> #mob is mobilization
> 
> d$pro <- as.numeric(as.character(d$prov))

> r <- is.na(d$pro)

> d$pro[r] <- 0

> d$prot <- as.numeric(as.character(d$prot))

> r <- is.na(d$prot)

> d$prot[r] <- 0

> d$com <- as.numeric(as.character(d$com))

> r <- is.na(d$com)

> d$com[r] <- 0

> d$mob <- as.numeric(as.character(d$mob))

> r <- is.na(d$mob)

> d$mob[r] <- 0

> d$eli.f <- as.numeric(as.character(d$elif))

> r <- is.na(d$eli.f)

> d$eli.f[r] <- 0

> d$eli.c <- as.numeric(as.character(d$elic))

> r <- is.na(d$eli.c)

> d$eli.c[r] <- 0

> #Background
> d$gender <- as.numeric(as.character(d$d1))-1

> d$gender.o <- d$gender

> d$gender.m <- is.na(d$gender)

> d$gender[d$gender.m==TRUE] <- 1

> d$age <- 2015 - (as.numeric(as.character(d$d3))+1929)

> d$age.o <- d$age

> d$age.m <- is.na(d$age)

> d$age[d$age.m==TRUE] <- 30

> #"[d6] What is the highest level of education you have received?"
> # 01 No formal education 02 Elementary school 03 Middle school
> # 04 High school
> # 05 College 06 Masters 07 Doctoral
> var <- d$d6

> var.r <- d$d6r

> out <- rep(NA, length(var))

> order.r <- rep(NA, length(var))

> r <- !is.na(as.numeric(as.character(var)))

> out[r] <- as.numeric(as.character(var))[r]

> order.r[r] <- 0

> r <- !is.na(as.numeric(as.character(var.r)))

> out[r] <- as.numeric(as.character(var.r))[r]

> order.r[r] <- 1

> d$educ <- out

> d$educ.o <- d$educ

> d$educ.m <- is.na(d$educ)

> d$educ[d$educ.m==TRUE] <- 3

> d$start.time.n <- as.numeric(d$start.time)-as.numeric(d$start.time[1])

> d$start.time.n2 <- (d$start.time.n)^2

> d$start.time.n3 <- (d$start.time.n)^3

> plot(d$start.time.n, d$start.time.n2)

> plot(d$start.time.n, d$start.time.n3)

> #Time dummy for after the first wave
> d$start.time.swd <- d$start.time > "2015-11-05 11:00:00 EST"

> median(d$na1.v, na.rm=T)
[1] 8

> d$na1.v2 <- d$na1.v

> d$na1.v2[is.na(d$na1.v)] <- 8 

> median(d$na2.v, na.rm=T)
[1] 3

> d$na2.v2 <- d$na2.v

> d$na2.v2[is.na(d$na2.v)] <- 3

> median(d$na3.v, na.rm=T)
[1] 3

> d$na3.v2 <- d$na3.v

> d$na3.v2[is.na(d$na3.v)] <- 3 

> median(d$asc0, na.rm=T)
[1] 4

> d$asc0.v2 <- d$asc0

> d$asc0.v2[is.na(d$asc0)] <- 4 

> #Mediators
> #Tests of Resolve
> #[tr] To what extent will other countries be more or less likely to challenge China in the future, if China doesn't defend its maritime interests more forcefully?
> d$tr.o <- d$tr_1

> d$trr.o <- d$trr_1

> var <- d$tr_1

> var.r <-d$trr_1

> out <- rep(NA, length(var))

> order.r <- rep(NA, length(var))

> r <- !is.na(as.numeric(as.character(var)))

> out[r] <- as.numeric(as.character(var))[r]

> order.r[r] <- 0

> r <- !is.na(as.numeric(as.character(var.r)))

> out[r] <- as.numeric(as.character(var.r))[r]

> order.r[r] <- 1

> d$tr <- out

> d$tr.or <- order.r

> summary(lm(d$tr ~ d$tr.or))

Call:
lm(formula = d$tr ~ d$tr.or)

Residuals:
    Min      1Q  Median      3Q     Max 
-6.9430 -1.9165  0.0835  2.0570  3.0835 

Coefficients:
            Estimate Std. Error t value            Pr(>|t|)    
(Intercept)  6.94302    0.06928  100.21 <0.0000000000000002 ***
d$tr.or     -0.02648    0.09798   -0.27               0.787    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 2.446 on 2490 degrees of freedom
  (749 observations deleted due to missingness)
Multiple R-squared:  2.934e-05,	Adjusted R-squared:  -0.0003723 
F-statistic: 0.07307 on 1 and 2490 DF,  p-value: 0.7869


> hist(d$tr)

> hist(as.numeric(as.character(var)), col="blue")

> hist(as.numeric(as.character(var.r)), add=TRUE, alpha=.3)

> #[lf] To what extent have recent events in China’s surrounding waters made China lose face?
> d$lf.o <- d$lf

> d$lfr.o <- d$lfr

> var <- d$lf.o

> var.r <-d$lfr.o

> out <- rep(NA, length(var))

> order.r <- rep(NA, length(var))

> r <- !is.na(as.numeric(as.character(var)))

> out[r] <- as.numeric(as.character(var))[r]

> order.r[r] <- 0

> r <- !is.na(as.numeric(as.character(var.r)))

> out[r] <- as.numeric(as.character(var.r))[r]

> order.r[r] <- 1

> d$lf <- out

> d$lf.or <- order.r

> summary(lm(d$lf ~ d$lf.or))

Call:
lm(formula = d$lf ~ d$lf.or)

Residuals:
    Min      1Q  Median      3Q     Max 
-1.6011 -0.6011 -0.4779  0.5221  1.5221 

Coefficients:
            Estimate Std. Error t value             Pr(>|t|)    
(Intercept)  2.47788    0.02980  83.155 < 0.0000000000000002 ***
d$lf.or      0.12325    0.04212   2.926              0.00346 ** 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.051 on 2487 degrees of freedom
  (752 observations deleted due to missingness)
Multiple R-squared:  0.003432,	Adjusted R-squared:  0.003031 
F-statistic: 8.564 on 1 and 2487 DF,  p-value: 0.00346


> hist(d$lf)

> hist(as.numeric(as.character(var)), col="blue")

> hist(as.numeric(as.character(var.r)), add=TRUE, alpha=.3)

> #Much more likely to select high levels of loss of face when high levels come first. 
> 
> 
> 
> # [nh] To what extent would you say that China’s national honor is at stake in this disagreement?
> # [0 national honor not at stake, 10 national honor very much at stake]
> 
> #[lf] To what extent have recent events in China’s surrounding waters made China lose face?
> d$nh.o <- d$nh_1

> d$nhr.o <- d$nhr_1

> var <- d$nh.o

> var.r <-d$nhr.o

> out <- rep(NA, length(var))

> order.r <- rep(NA, length(var))

> r <- !is.na(as.numeric(as.character(var)))

> out[r] <- as.numeric(as.character(var))[r]

> order.r[r] <- 0

> r <- !is.na(as.numeric(as.character(var.r)))

> out[r] <- as.numeric(as.character(var.r))[r]

> order.r[r] <- 1

> d$nh <- out

> d$nh.or <- order.r

> summary(lm(d$nh ~ d$nh.or))

Call:
lm(formula = d$nh ~ d$nh.or)

Residuals:
    Min      1Q  Median      3Q     Max 
-5.7860 -1.7860  0.2866  2.2866  4.2866 

Coefficients:
            Estimate Std. Error t value            Pr(>|t|)    
(Intercept)  5.78600    0.08372  69.107 <0.0000000000000002 ***
d$nh.or     -0.07264    0.11843  -0.613                0.54    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 2.952 on 2483 degrees of freedom
  (756 observations deleted due to missingness)
Multiple R-squared:  0.0001515,	Adjusted R-squared:  -0.0002512 
F-statistic: 0.3762 on 1 and 2483 DF,  p-value: 0.5397


> hist(d$nh)

> hist(as.numeric(as.character(var)), col="blue")

> hist(as.numeric(as.character(var.r)), add=TRUE, alpha=.3)

> #Lots select 0, and doesn't seem to be driven by anchor. 
> 
> 
> 
> #[thr] To what extent have recent events in China’s surrounding waters made China lose face?
> d$thr.o <- d$thr

> d$thrr.o <- d$thrr

> var <- d$thr.o

> var.r <-d$thrr.o

> out <- rep(NA, length(var))

> order.r <- rep(NA, length(var))

> r <- !is.na(as.numeric(as.character(var)))

> out[r] <- as.numeric(as.character(var))[r]

> order.r[r] <- 0

> r <- !is.na(as.numeric(as.character(var.r)))

> out[r] <- as.numeric(as.character(var.r))[r]

> order.r[r] <- 1

> d$thr <- out

> d$thr.or <- order.r

> summary(lm(out ~ order.r))

Call:
lm(formula = out ~ order.r)

Residuals:
    Min      1Q  Median      3Q     Max 
-1.7895 -0.6675  0.2105  0.3325  1.3325 

Coefficients:
            Estimate Std. Error t value             Pr(>|t|)    
(Intercept)  2.66747    0.02236 119.307 < 0.0000000000000002 ***
order.r      0.12204    0.03163   3.858             0.000117 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.7879 on 2480 degrees of freedom
  (759 observations deleted due to missingness)
Multiple R-squared:  0.005967,	Adjusted R-squared:  0.005566 
F-statistic: 14.89 on 1 and 2480 DF,  p-value: 0.0001171


> hist(out)

> hist(as.numeric(as.character(var)), col="blue")

> hist(as.numeric(as.character(var.r)), add=TRUE, alpha=.3)

> #Lots select 0, and doesn't seem to be driven by anchor. 
> 
> 
> write.csv(d, "./MASTER CODE/hyp.csv")

> save(d, file="./MASTER CODE/hyp.Rdata")

> #------------------------------------------------------------------------------------------
> ## Constructing Publishable dataset. 
> #------------------------------------------------------------------------------------------
> 
> keepvars <- c("asc", "asc0", "pro", "prot", "com", "mob", "eli.f", "eli.c", 
+     "authoritarian", "ally", "capabilities", "salience", "his",
+     "pre.questions", "asc.or", "asc0.v2", "na1.v2", "na2.v2", "na3.v2",
+     "na2.v.dn", "na3.v.dn", "start.time", "start.time.n", "start.time.n2", "start.time.n3",
+     "start.time.swd", "att", "rac", "rac.or", "ra3c", "na1.v", "na2.v", "na3.v", "a.pcono") ##variables that are not identifiable

> data.share <- d[, names(d) %in% keepvars]

> write.csv(data.share, "./MASTER CODE/hyp_toshare.csv") 

> d <- read.csv("./hyp_toshare.csv") #analysis data keeps only non-identifiable variables. 

> #generating random numbers of identifiable variables
> set.seed(2018)

> d$gender <- sample(c(0,1), size=nrow(d), replace=TRUE, prob=c(.39,.61))

> d$educ <- sample(seq(from = 1, to = 7, by = 1), size = nrow(d), replace = TRUE, prob=c(0.002, 0.00, 0.402,  0.067, 0.470, 0.054, 0.005))

> d$age <- sample(c( 6,11,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32, 
+                    33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50, 
+                    51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68 ,
+                    69,70,71,72,73,85),
+                 size=nrow(d), replace=TRUE, 
+                 prob=c(0.0003, 0.0003, 0.0006, 0.0025, 0.0039, 0.0066, 0.0063, 0.0132, 0.0113, 0.0121, 0.0215, 0.0157, 0.0212, 
+                        0.0251, 0.0240, 0.4307, 0.0196, 0.0317, 0.0287, 0.0259, 0.0389, 0.0245, 0.0187, 0.0207, 0.0204, 0.0185,
+                        0.0143, 0.0149, 0.0110, 0.0105, 0.0141, 0.0094, 0.0066, 0.0063, 0.0052, 0.0050, 0.0036, 0.0091, 0.0066,
+                        0.0044, 0.0033, 0.0025, 0.0033, 0.0025, 0.0039, 0.0025, 0.0028, 0.0022, 0.0017, 0.0017, 0.0022, 0.0011,
+                        0.0014, 0.0011, 0.0003, 0.0014, 0.0014, 0.0003, 0.0006, 0.0003))

> d$partner <- sample(c("A", "B"), size=nrow(d), replace=TRUE, prob=c(.551, 0.449)) 

> #Gen other variables 
> d$gender.o <- d$gender

> d$gender.m <- is.na(d$gender)

> d$gender[d$gender.m==TRUE] <- 1

> d$age.o <- d$age

> d$age.m <- is.na(d$age)

> d$age[d$age.m==TRUE] <- 30

> d$educ.o <- d$educ

> d$educ.m <- is.na(d$educ)

> d$educ[d$educ.m==TRUE] <- 3

> write.csv(d, "./MASTER CODE/hypanalysis.csv")

> save(d, file="./MASTER CODE/hypanalysis.Rdata")

> #-----------------------------------------------------------------------------------------
> #Replication Main Text and Appendix
> #-----------------------------------------------------------------------------------------
> 
> 
> {{format(Sys.Date(), format="%B %d %Y")}}
[1] "February 13 2019"

> #+ opts, include=FALSE,eval=TRUE
> knitr::opts_chunk$set(eval=TRUE, echo=TRUE, error=TRUE,message=FALSE, warning=FALSE,
+                       fig.width=15, fig.height=5,width=60,dev="pdf"
+ )

> rm(list = ls())

> setwd("~/Dropbox/Dafoe-Weiss-Empirics/18-04-12-ISQ-Raluca/Code/Replication File ISQ/")

> load("./MASTER CODE/hyp.Rdata")

> rb <- rep(1, length(d[,1]))

> #Figures location
> fig.loc <- "../../Figures/"

> #Packages
> require(ggplot2)

> require(reshape2)

> require(coefplot)

> require(robustbase)

> require(rms)

> require(sandwich)

> require(stargazer)

> w <- 5

> h <- 4

> #finding value of Z that gives 10% one sided test
> xs <- seq(-2,0, 0.01)

> xs[which(pnorm(xs)-0.05==min(abs(pnorm(xs)-0.05)))]
[1] -1.64

> pnorm(-1.64)
[1] 0.05050258

> pnorm(-1.96)
[1] 0.0249979

> innerCI.n <- 1.64 #set so exclusion of CI implies two sided significance of 0.1

> outerCI.n <- 1.96 #set so exclusion of CI implies two sided significance of 0.05

> # Customized Stargazer Function, without asterisk inflation
> stargazerAD <- function(table, title="Default", filename="Figures/default.tex", dep.var.labels=NULL) {
+   a <- stargazer(table, title=title,  out=filename, 
+                  align=TRUE, star.cutoffs = c(0.1, 0.05, 0.01, 0.001), star.char = c("\\dagger", "*", "**", "***"), 
+                  notes="$^{\\dagger} p<0.1$; $^{*} p<0.05$; $^{**} p<0.01$; $^{***} p<0.001$", notes.append=FALSE, single.row=TRUE)
+   return(a)
+ }

> results.fun <- function(data, r, model, title.w, fig.loc, coefficients=NULL, innerCI.n=1.64, outerCI.n=1.96, w=10, h=6) {
+   d <- data
+   #rob.results <- robcov(ols(model, dat=d[r,], x=TRUE))
+   m1 <-  lm(model,  dat=d[r,])
+   homo.results <- summary(m1)
+   n <- length(d[r,1])
+   title <- paste(title.w, ", n=", n, sep="")
+   pf <- coefplot(m1, title=title, 
+                  intercept=FALSE, lwdOuter=0.5, innerCI=innerCI.n, outerCI= outerCI.n,
+                  coefficients=coefficients) + theme_bw()
+   fig.results <- pf
+   list.results <- list("homo.results"=homo.results, "title"=title, "fig.results"=fig.results, "model"=m1, m1)
+   return(list.results)
+ }

> ## Number of observations ##
> n.obs <- sum(table(d$asc))

> cat(n.obs, file=paste(fig.loc,"Hyp-n.tex", sep=""))

> n.obs.att <- sum(d$att) 

> cat(n.obs.att, file=paste(fig.loc,"Hyp-n-att.tex", sep=""))

> #From PAP: 
> #For our primary specification we will estimate the effects of our manipulations using OLS with heteroscedasticity consis- tent standard errors, conditioning on the other experimental conditions to increase power. Hypothesis tests will be one-sided when appropriate. We will also report our estimates of the average causal effect when not conditioning on anything else, an estimand termed the average marginal component effect by Hainmueller, Hopkins, and Yamamoto.37
> #Our primary test of these hypotheses will involve OLS regression, controlling for the other experimental conditions, and in the real-history design for the pre-scenario answers to the same questions. 
> #robcov(ols(y ~ a.1 * a.2, toyData, x = TRUE)) ## heteroskedastic (ATE)
> 
> #' ### Results for Approval ###
> 
> #r <-  rep(1, length(d[,1]))
> r <- !is.na(d$asc) & rb

> type <- "Hyp"

> outcome <- "Approval"

> cont <- ""

> title.w <- paste(type, ", Effect on ", outcome, cont, sep="")

> title.f <- paste(type, "-", outcome, cont, sep="")

> coefficients.list<- c("his", "pro", "com", "mob", "eli.f", "eli.c")

> model <- asc ~ pro + prot + com + mob + eli.f + eli.c + 
+   authoritarian + ally + capabilities + salience + his +
+   pre.questions + asc.or 

> results <- results.fun(data=d, r=r, model=model, title.w=title.w, fig.loc=fig.loc, coefficients=coefficients.list, innerCI.n=innerCI.n, outerCI.n=outerCI.n, w=w, h=h)

> results[1]
$homo.results

Call:
lm(formula = model, data = d[r, ])

Residuals:
     Min       1Q   Median       3Q      Max 
-2.28061 -0.90525  0.04006  0.92460  2.27964 

Coefficients:
               Estimate Std. Error t value             Pr(>|t|)    
(Intercept)    2.928262   0.067966  43.084 < 0.0000000000000002 ***
pro           -0.090454   0.047022  -1.924               0.0545 .  
prot          -0.029422   0.060369  -0.487               0.6260    
com           -0.069415   0.047103  -1.474               0.1407    
mob            0.007561   0.047379   0.160               0.8732    
eli.f          0.120304   0.077198   1.558               0.1193    
eli.c          0.039932   0.077000   0.519               0.6041    
authoritarian -0.018126   0.040107  -0.452               0.6513    
ally          -0.005597   0.040079  -0.140               0.8890    
capabilities  -0.020034   0.040128  -0.499               0.6176    
salience       0.001654   0.040179   0.041               0.9672    
his            0.043405   0.040088   1.083               0.2790    
pre.questions -0.042437   0.047171  -0.900               0.3684    
asc.or         0.235016   0.040124   5.857        0.00000000522 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.095 on 2978 degrees of freedom
Multiple R-squared:  0.01541,	Adjusted R-squared:  0.01111 
F-statistic: 3.584 on 13 and 2978 DF,  p-value: 0.00001258



> results[2]
$title
[1] "Hyp, Effect on Approval, n=2992"


> results$fig.results

> coefplot(lm(model, data=d[r,]), title=title.w, 
+          intercept=FALSE, lwdOuter=0.5, innerCI=innerCI.n, outerCI= outerCI.n, data=d) + theme_bw()

> pdf(paste(fig.loc,title.f,".pdf", sep=""), width=w, height=h)

> results$fig.results

> dev.off()
RStudioGD 
        2 

> m11 <- results[4]

> pro.results <- coef(summary(results$model))["pro",]

> toprint <- paste("p_{+}=",round(pro.results[4]/2,3),  sep="")

> write(toprint, file=paste(fig.loc,type,outcome,"p",".tex", sep=""))

> statement.results <- coef(summary(results$model))[c("com", "mob", "his", "eli.f","eli.c"),]

> #Checking if provocation or statement of commitment interacts with eli.f or eli.c.
> #Audience costs arise if pro or com decrease approval (negative effect). Eli would reduce audience costs if they have a positive interaction. 
> 
> model <- asc ~ com + pro + prot + com*eli.f + com*eli.c + pro*eli.f + pro*eli.c + mob + eli.f + eli.c +
+   authoritarian + ally + capabilities + salience + his +
+   pre.questions + asc.or 

> coefplot(lm(model, data=d[r,]), title=title.w, 
+          intercept=FALSE, lwdOuter=0.5, innerCI=innerCI.n, outerCI= outerCI.n, data=d) + theme_bw()

> #Result: largely insignificant, but if anything statement of commitments and elite cue framing negatively interact. So people disapprove more if you make a statement of commitment, and then offer a biding time argument for justifying backing down, perhaps because you are revealing inconsistency (but why not same result for eli.c?). 
> 
> 
> 
> r <- !is.na(d$asc) & rb

> type <- "Hyp"

> outcome <- "Approval"

> cont <- "Covariates"

> title.w <- paste(type, ", Effect on ", outcome, ", Controlling ", cont, sep="")

> title.f <- paste(type, "-", outcome, cont, sep="")

> #coefficients.list<- c("his", "pro", "prot", "com", "mob", "eli.f", "eli.c")
> coefficients.list<- c("his", "pro", "com", "mob", "eli.f", "eli.c")

> model <- asc ~ pro + prot + com + mob + eli.f + eli.c + 
+   authoritarian + ally + capabilities + salience + his +
+   pre.questions + asc.or +  partner + asc.or + asc0.v2  +
+   na1.v2 + na2.v2 + na3.v2 + na2.v.dn + na3.v.dn + gender + educ + age + age.m + gender.m + educ.m + 
+   start.time.n + start.time.n2 + start.time.n3 + start.time.swd 

> results <- results.fun(data=d, r=r, model=model, title.w=title.w, fig.loc=fig.loc, coefficients=coefficients.list, innerCI.n=innerCI.n, outerCI.n=outerCI.n, w=w, h=h)

> results[1]
$homo.results

Call:
lm(formula = model, data = d[r, ])

Residuals:
     Min       1Q   Median       3Q      Max 
-3.09882 -0.77354  0.01316  0.81596  2.83023 

Coefficients: (3 not defined because of singularities)
                                    Estimate                Std. Error t value             Pr(>|t|)    
(Intercept)         2.9819804999129213562981  0.2915553768551970570400  10.228 < 0.0000000000000002 ***
pro                -0.1080232863077450200517  0.0445962123898629506091  -2.422             0.015484 *  
prot               -0.0453854706472335625578  0.0571845332835848735309  -0.794             0.427453    
com                -0.0558593850403135347427  0.0446327841836056740665  -1.252             0.210839    
mob                 0.0527281596456104922899  0.0449637366762564785749   1.173             0.241018    
eli.f               0.0932903194820232789519  0.0732032848750524822723   1.274             0.202621    
eli.c               0.0257870415810308416249  0.0730197497977829179661   0.353             0.724000    
authoritarian      -0.0256060942492873366838  0.0379933864743483909465  -0.674             0.500388    
ally               -0.0117164136291435603404  0.0379418412052473855156  -0.309             0.757496    
capabilities       -0.0214203022874623685845  0.0380370632748009002144  -0.563             0.573380    
salience            0.0086440498332279007421  0.0380645154958717812921   0.227             0.820370    
his                 0.0304086653343214469158  0.0380246717275291024052   0.800             0.423944    
pre.questions      -0.1070185162741375400897  0.0569230602505150506953  -1.880             0.060199 .  
asc.or              0.2263062100256388320396  0.0379945765797024825883   5.956        0.00000000288 ***
partnerB           -0.1260308450995186180243  0.0568099829448085250072  -2.218             0.026599 *  
asc0.v2             0.3386975971650759698051  0.0267376495949683268272  12.667 < 0.0000000000000002 ***
na1.v2             -0.0415187409947923025122  0.0119396853163952140764  -3.477             0.000514 ***
na2.v2             -0.2017709445826488257048  0.0350184193542793578691  -5.762        0.00000000917 ***
na3.v2              0.0230568949088497433808  0.0240954462249529342832   0.957             0.338697    
na2.v.dn           -0.0395892865127912274570  0.1013708229410628519629  -0.391             0.696166    
na3.v.dn           -0.1784566126032469113305  0.1436106068559747372948  -1.243             0.214098    
gender              0.0715394292182252033996  0.0490616604316732457525   1.458             0.144904    
educ               -0.0999122981030557411053  0.0404651843607386138557  -2.469             0.013602 *  
age                -0.0064110981341401543365  0.0023392038126082100903  -2.741             0.006167 ** 
age.mTRUE           0.1309972617794172844441  0.0969379998352877109147   1.351             0.176686    
gender.mTRUE                              NA                        NA      NA                   NA    
educ.mTRUE                                NA                        NA      NA                   NA    
start.time.n        0.0000000232446796181408  0.0000001638308353615063   0.142             0.887183    
start.time.n2       0.0000000000005115366969  0.0000000000003851144765   1.328             0.184191    
start.time.n3      -0.0000000000000000003674  0.0000000000000000002038  -1.803             0.071534 .  
start.time.swdTRUE                        NA                        NA      NA                   NA    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.036 on 2964 degrees of freedom
Multiple R-squared:  0.1234,	Adjusted R-squared:  0.1154 
F-statistic: 15.46 on 27 and 2964 DF,  p-value: < 0.00000000000000022



> results[2] 
$title
[1] "Hyp, Effect on Approval, Controlling Covariates, n=2992"


> results$fig.results

> coefplot(lm(model, data=d[r,]), title=title.w, 
+          intercept=FALSE, lwdOuter=0.5, innerCI=innerCI.n, outerCI= outerCI.n, data=d) + theme_bw()

> pdf(paste(fig.loc,title.f,".pdf", sep=""), width=w, height=h)

> results$fig.results

> dev.off()
RStudioGD 
        2 

> m12 <- results[4]

> stargazerAD(c(m11, m12), title="Effect on Approval, Hypothetical", filename=paste(fig.loc,title.f,"-table",".tex", sep=""))

% Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu
% Date and time: Wed, Feb 13, 2019 - 13:49:20
% Requires LaTeX packages: dcolumn 
\begin{table}[!htbp] \centering 
  \caption{Effect on Approval, Hypothetical} 
  \label{} 
\begin{tabular}{@{\extracolsep{5pt}}lD{.}{.}{-3} D{.}{.}{-3} } 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
 & \multicolumn{2}{c}{\textit{Dependent variable:}} \\ 
\cline{2-3} 
\\[-1.8ex] & \multicolumn{2}{c}{asc} \\ 
\\[-1.8ex] & \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)}\\ 
\hline \\[-1.8ex] 
 pro & -0.090^{\dagger}$ $(0.047) & -0.108^{*}$ $(0.045) \\ 
  prot & -0.029$ $(0.060) & -0.045$ $(0.057) \\ 
  com & -0.069$ $(0.047) & -0.056$ $(0.045) \\ 
  mob & 0.008$ $(0.047) & 0.053$ $(0.045) \\ 
  eli.f & 0.120$ $(0.077) & 0.093$ $(0.073) \\ 
  eli.c & 0.040$ $(0.077) & 0.026$ $(0.073) \\ 
  authoritarian & -0.018$ $(0.040) & -0.026$ $(0.038) \\ 
  ally & -0.006$ $(0.040) & -0.012$ $(0.038) \\ 
  capabilities & -0.020$ $(0.040) & -0.021$ $(0.038) \\ 
  salience & 0.002$ $(0.040) & 0.009$ $(0.038) \\ 
  his & 0.043$ $(0.040) & 0.030$ $(0.038) \\ 
  pre.questions & -0.042$ $(0.047) & -0.107^{\dagger}$ $(0.057) \\ 
  asc.or & 0.235^{***}$ $(0.040) & 0.226^{***}$ $(0.038) \\ 
  partnerB &  & -0.126^{*}$ $(0.057) \\ 
  asc0.v2 &  & 0.339^{***}$ $(0.027) \\ 
  na1.v2 &  & -0.042^{***}$ $(0.012) \\ 
  na2.v2 &  & -0.202^{***}$ $(0.035) \\ 
  na3.v2 &  & 0.023$ $(0.024) \\ 
  na2.v.dn &  & -0.040$ $(0.101) \\ 
  na3.v.dn &  & -0.178$ $(0.144) \\ 
  gender &  & 0.072$ $(0.049) \\ 
  educ &  & -0.100^{*}$ $(0.040) \\ 
  age &  & -0.006^{**}$ $(0.002) \\ 
  age.m &  & 0.131$ $(0.097) \\ 
  gender.m &  &  \\ 
  educ.m &  &  \\ 
  start.time.n &  & 0.00000$ $(0.00000) \\ 
  start.time.n2 &  & 0.000$ $(0.000) \\ 
  start.time.n3 &  & -0.000^{\dagger}$ $(0.000) \\ 
  start.time.swd &  &  \\ 
  Constant & 2.928^{***}$ $(0.068) & 2.982^{***}$ $(0.292) \\ 
 \hline \\[-1.8ex] 
Observations & \multicolumn{1}{c}{2,992} & \multicolumn{1}{c}{2,992} \\ 
R$^{2}$ & \multicolumn{1}{c}{0.015} & \multicolumn{1}{c}{0.123} \\ 
Adjusted R$^{2}$ & \multicolumn{1}{c}{0.011} & \multicolumn{1}{c}{0.115} \\ 
Residual Std. Error & \multicolumn{1}{c}{1.095 (df = 2978)} & \multicolumn{1}{c}{1.036 (df = 2964)} \\ 
F Statistic & \multicolumn{1}{c}{3.584$^{***}$ (df = 13; 2978)} & \multicolumn{1}{c}{15.458$^{***}$ (df = 27; 2964)} \\ 
\hline 
\hline \\[-1.8ex] 
\textit{Note:}  & \multicolumn{2}{r}{$^{\dagger} p<0.1$; $^{*} p<0.05$; $^{**} p<0.01$; $^{***} p<0.001$} \\ 
\end{tabular} 
\end{table} 
 [1] ""                                                                                                                            
 [2] "% Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu"                 
 [3] "% Date and time: Wed, Feb 13, 2019 - 13:49:20"                                                                               
 [4] "% Requires LaTeX packages: dcolumn "                                                                                         
 [5] "\\begin{table}[!htbp] \\centering "                                                                                          
 [6] "  \\caption{Effect on Approval, Hypothetical} "                                                                              
 [7] "  \\label{} "                                                                                                                
 [8] "\\begin{tabular}{@{\\extracolsep{5pt}}lD{.}{.}{-3} D{.}{.}{-3} } "                                                           
 [9] "\\\\[-1.8ex]\\hline "                                                                                                        
[10] "\\hline \\\\[-1.8ex] "                                                                                                       
[11] " & \\multicolumn{2}{c}{\\textit{Dependent variable:}} \\\\ "                                                                 
[12] "\\cline{2-3} "                                                                                                               
[13] "\\\\[-1.8ex] & \\multicolumn{2}{c}{asc} \\\\ "                                                                               
[14] "\\\\[-1.8ex] & \\multicolumn{1}{c}{(1)} & \\multicolumn{1}{c}{(2)}\\\\ "                                                     
[15] "\\hline \\\\[-1.8ex] "                                                                                                       
[16] " pro & -0.090^{\\dagger}$ $(0.047) & -0.108^{*}$ $(0.045) \\\\ "                                                             
[17] "  prot & -0.029$ $(0.060) & -0.045$ $(0.057) \\\\ "                                                                          
[18] "  com & -0.069$ $(0.047) & -0.056$ $(0.045) \\\\ "                                                                           
[19] "  mob & 0.008$ $(0.047) & 0.053$ $(0.045) \\\\ "                                                                             
[20] "  eli.f & 0.120$ $(0.077) & 0.093$ $(0.073) \\\\ "                                                                           
[21] "  eli.c & 0.040$ $(0.077) & 0.026$ $(0.073) \\\\ "                                                                           
[22] "  authoritarian & -0.018$ $(0.040) & -0.026$ $(0.038) \\\\ "                                                                 
[23] "  ally & -0.006$ $(0.040) & -0.012$ $(0.038) \\\\ "                                                                          
[24] "  capabilities & -0.020$ $(0.040) & -0.021$ $(0.038) \\\\ "                                                                  
[25] "  salience & 0.002$ $(0.040) & 0.009$ $(0.038) \\\\ "                                                                        
[26] "  his & 0.043$ $(0.040) & 0.030$ $(0.038) \\\\ "                                                                             
[27] "  pre.questions & -0.042$ $(0.047) & -0.107^{\\dagger}$ $(0.057) \\\\ "                                                      
[28] "  asc.or & 0.235^{***}$ $(0.040) & 0.226^{***}$ $(0.038) \\\\ "                                                              
[29] "  partnerB &  & -0.126^{*}$ $(0.057) \\\\ "                                                                                  
[30] "  asc0.v2 &  & 0.339^{***}$ $(0.027) \\\\ "                                                                                  
[31] "  na1.v2 &  & -0.042^{***}$ $(0.012) \\\\ "                                                                                  
[32] "  na2.v2 &  & -0.202^{***}$ $(0.035) \\\\ "                                                                                  
[33] "  na3.v2 &  & 0.023$ $(0.024) \\\\ "                                                                                         
[34] "  na2.v.dn &  & -0.040$ $(0.101) \\\\ "                                                                                      
[35] "  na3.v.dn &  & -0.178$ $(0.144) \\\\ "                                                                                      
[36] "  gender &  & 0.072$ $(0.049) \\\\ "                                                                                         
[37] "  educ &  & -0.100^{*}$ $(0.040) \\\\ "                                                                                      
[38] "  age &  & -0.006^{**}$ $(0.002) \\\\ "                                                                                      
[39] "  age.m &  & 0.131$ $(0.097) \\\\ "                                                                                          
[40] "  gender.m &  &  \\\\ "                                                                                                      
[41] "  educ.m &  &  \\\\ "                                                                                                        
[42] "  start.time.n &  & 0.00000$ $(0.00000) \\\\ "                                                                               
[43] "  start.time.n2 &  & 0.000$ $(0.000) \\\\ "                                                                                  
[44] "  start.time.n3 &  & -0.000^{\\dagger}$ $(0.000) \\\\ "                                                                      
[45] "  start.time.swd &  &  \\\\ "                                                                                                
[46] "  Constant & 2.928^{***}$ $(0.068) & 2.982^{***}$ $(0.292) \\\\ "                                                            
[47] " \\hline \\\\[-1.8ex] "                                                                                                      
[48] "Observations & \\multicolumn{1}{c}{2,992} & \\multicolumn{1}{c}{2,992} \\\\ "                                                
[49] "R$^{2}$ & \\multicolumn{1}{c}{0.015} & \\multicolumn{1}{c}{0.123} \\\\ "                                                     
[50] "Adjusted R$^{2}$ & \\multicolumn{1}{c}{0.011} & \\multicolumn{1}{c}{0.115} \\\\ "                                            
[51] "Residual Std. Error & \\multicolumn{1}{c}{1.095 (df = 2978)} & \\multicolumn{1}{c}{1.036 (df = 2964)} \\\\ "                 
[52] "F Statistic & \\multicolumn{1}{c}{3.584$^{***}$ (df = 13; 2978)} & \\multicolumn{1}{c}{15.458$^{***}$ (df = 27; 2964)} \\\\ "
[53] "\\hline "                                                                                                                    
[54] "\\hline \\\\[-1.8ex] "                                                                                                       
[55] "\\textit{Note:}  & \\multicolumn{2}{r}{$^{\\dagger} p<0.1$; $^{*} p<0.05$; $^{**} p<0.01$; $^{***} p<0.001$} \\\\ "          
[56] "\\end{tabular} "                                                                                                             
[57] "\\end{table} "                                                                                                               

> smalld <- d[,c("asc", "asc0", "his", "pro", "prot", "com", "mob", "eli.f", "eli.c", 
+                "authoritarian", "ally", "capabilities", "salience",  
+                "pre.questions", "asc.or", "partner", 
+                "na1.v", "na2.v", "na3.v", "na2.v.dn", "na3.v.dn", "gender.o", "educ.o", "age.o",
+                "age.m", "gender.m", "educ.m")]

> #, "start.time.n", "start.time.n2", "start.time.n3", "start.time.swd"
> stargazer(smalld, title="Summary Statistics", out=paste(fig.loc, "summary-statistics-hypothetical",".tex", sep=""))

% Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu
% Date and time: Wed, Feb 13, 2019 - 13:49:20
\begin{table}[!htbp] \centering 
  \caption{Summary Statistics} 
  \label{} 
\begin{tabular}{@{\extracolsep{5pt}}lccccccc} 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
Statistic & \multicolumn{1}{c}{N} & \multicolumn{1}{c}{Mean} & \multicolumn{1}{c}{St. Dev.} & \multicolumn{1}{c}{Min} & \multicolumn{1}{c}{Pctl(25)} & \multicolumn{1}{c}{Pctl(75)} & \multicolumn{1}{c}{Max} \\ 
\hline \\[-1.8ex] 
asc & 2,992 & 2.985 & 1.101 & 1.000 & 2.000 & 4.000 & 5.000 \\ 
asc0 & 2,345 & 3.835 & 0.873 & 1.000 & 3.000 & 4.000 & 5.000 \\ 
his & 3,241 & 0.467 & 0.499 & 0 & 0 & 1 & 1 \\ 
pro & 3,241 & 0.226 & 0.419 & 0 & 0 & 0 & 1 \\ 
prot & 3,241 & 0.118 & 0.323 & 0 & 0 & 0 & 1 \\ 
com & 3,241 & 0.223 & 0.416 & 0 & 0 & 0 & 1 \\ 
mob & 3,241 & 0.222 & 0.416 & 0 & 0 & 0 & 1 \\ 
eli.f & 3,241 & 0.069 & 0.253 & 0 & 0 & 0 & 1 \\ 
eli.c & 3,241 & 0.068 & 0.253 & 0 & 0 & 0 & 1 \\ 
authoritarian & 3,241 & 0.466 & 0.499 & 0 & 0 & 1 & 1 \\ 
ally & 3,241 & 0.465 & 0.499 & 0 & 0 & 1 & 1 \\ 
capabilities & 3,241 & 0.464 & 0.499 & 0 & 0 & 1 & 1 \\ 
salience & 3,241 & 0.466 & 0.499 & 0 & 0 & 1 & 1 \\ 
pre.questions & 3,241 & 0.712 & 0.453 & 0 & 0 & 1 & 1 \\ 
asc.or & 2,992 & 0.500 & 0.500 & 0.000 & 0.000 & 1.000 & 1.000 \\ 
na1.v & 2,308 & 8.012 & 1.974 & 0.000 & 7.000 & 10.000 & 10.000 \\ 
na2.v & 2,308 & 2.438 & 0.639 & 1.000 & 2.000 & 3.000 & 3.000 \\ 
na3.v & 2,308 & 3.229 & 0.916 & 1.000 & 3.000 & 4.000 & 5.000 \\ 
na2.v.dn & 3,241 & 0.044 & 0.206 & 0 & 0 & 0 & 1 \\ 
na3.v.dn & 3,241 & 0.021 & 0.143 & 0 & 0 & 0 & 1 \\ 
gender.o & 2,019 & 0.353 & 0.478 & 0.000 & 0.000 & 1.000 & 1.000 \\ 
educ.o & 2,019 & 4.960 & 0.576 & 1.000 & 5.000 & 5.000 & 7.000 \\ 
age.o & 2,019 & 35.872 & 10.157 & 6.000 & 29.000 & 41.000 & 85.000 \\ 
age.m & 3,241 & 0.377 & 0.485 & 0 & 0 & 1 & 1 \\ 
gender.m & 3,241 & 0.377 & 0.485 & 0 & 0 & 1 & 1 \\ 
educ.m & 3,241 & 0.377 & 0.485 & 0 & 0 & 1 & 1 \\ 
\hline \\[-1.8ex] 
\end{tabular} 
\end{table} 

> ## Summary statistics for variables ##
> asc ~ pro + prot + com + mob + eli.f + eli.c + 
+   authoritarian + ally + capabilities + salience + his +
+   pre.questions + asc.or +  partner + asc.or + asc0.v2  +
+   na1.v2 + na2.v2 + na3.v2 + na2.v.dn + na3.v.dn + gender + educ + age + age.m + gender.m + educ.m + 
+   start.time.n + start.time.n2 + start.time.n3 + start.time.swd 
asc ~ pro + prot + com + mob + eli.f + eli.c + authoritarian + 
    ally + capabilities + salience + his + pre.questions + asc.or + 
    partner + asc.or + asc0.v2 + na1.v2 + na2.v2 + na3.v2 + na2.v.dn + 
    na3.v.dn + gender + educ + age + age.m + gender.m + educ.m + 
    start.time.n + start.time.n2 + start.time.n3 + start.time.swd

> pro.results <- rbind(pro.results, coef(summary(results$model))["pro",])

> row.names(pro.results) <- c("approval", "approval, cov")

> statement.results <- rbind(statement.results, coef(summary(results$model))[c("com", "mob", "his", "eli.f","eli.c"),])

> l1 <- length(statement.results[,1])

> row.names(statement.results) <- paste(row.names(statement.results), rep(", ", l1), c(rep("approval",l1/2), rep("approval, cov", l1/2)), sep="")

> ## Replicate analysis without inattentive respondents
> ## Added by RP on 9/18/2017
> r <- !is.na(d$asc) & rb

> type <- "Inattentive-Hyp"

> outcome <- "Approval"

> cont <- ""

> title.w <- paste(type, ", Effect on ", outcome, cont, sep="")

> title.f <- paste(type, "-", outcome, cont, sep="")

> #coefficients.list<- c("his", "pro", "prot", "com", "mob", "eli.f", "eli.c")
> coefficients.list<- c("his", "pro", "com", "mob", "eli.f", "eli.c")

> model <- asc ~ pro + prot + com + mob + eli.f + eli.c + 
+   authoritarian + ally + capabilities + salience + his +
+   pre.questions + asc.or 

> results <- results.fun(data=d[d$att==1,], r=r, model=model, title.w=title.w, fig.loc=fig.loc, coefficients=coefficients.list, innerCI.n=innerCI.n, outerCI.n=outerCI.n, w=w, h=h)

> results[1]
$homo.results

Call:
lm(formula = model, data = d[r, ])

Residuals:
     Min       1Q   Median       3Q      Max 
-2.08197 -0.84936  0.09535  1.06956  2.39806 

Coefficients:
               Estimate Std. Error t value            Pr(>|t|)    
(Intercept)    2.849931   0.086227  33.052 <0.0000000000000002 ***
pro           -0.079671   0.059715  -1.334              0.1823    
prot           0.015159   0.076671   0.198              0.8433    
com           -0.052711   0.059751  -0.882              0.3778    
mob           -0.009217   0.059266  -0.156              0.8764    
eli.f          0.168543   0.103133   1.634              0.1024    
eli.c          0.067834   0.100979   0.672              0.5018    
authoritarian -0.021583   0.051230  -0.421              0.6736    
ally          -0.053794   0.051123  -1.052              0.2928    
capabilities  -0.054682   0.051228  -1.067              0.2859    
salience       0.018843   0.051262   0.368              0.7132    
his            0.053030   0.051188   1.036              0.3003    
pre.questions -0.061810   0.059039  -1.047              0.2953    
asc.or         0.163901   0.051212   3.200              0.0014 ** 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.111 on 1882 degrees of freedom
  (1096 observations deleted due to missingness)
Multiple R-squared:  0.01109,	Adjusted R-squared:  0.004255 
F-statistic: 1.623 on 13 and 1882 DF,  p-value: 0.07211



> results[2]
$title
[1] "Inattentive-Hyp, Effect on Approval, n=2992"


> m11_inattentive <- results[4]

> r <- !is.na(d$asc) & rb

> type <- "Inattentive-Hyp"

> outcome <- "Approval"

> cont <- "Covariates"

> title.w <- paste(type, ", Effect on ", outcome, ", Controlling ", cont, sep="")

> title.f <- paste(type, "-", outcome, cont, sep="")

> #coefficients.list<- c("his", "pro", "prot", "com", "mob", "eli.f", "eli.c")
> coefficients.list<- c("his", "pro", "com", "mob", "eli.f", "eli.c")

> model <- asc ~ pro + prot + com + mob + eli.f + eli.c + 
+   authoritarian + ally + capabilities + salience + his +
+   pre.questions + asc.or +  partner + asc.or + asc0.v2  +
+   na1.v2 + na2.v2 + na3.v2 + na2.v.dn + na3.v.dn + gender + educ + age + age.m + gender.m + educ.m + 
+   start.time.n + start.time.n2 + start.time.n3 + start.time.swd 

> results <- results.fun(data=d[d$att==1,], r=r, model=model, title.w=title.w, fig.loc=fig.loc, coefficients=coefficients.list, innerCI.n=innerCI.n, outerCI.n=outerCI.n, w=w, h=h)

> results[1]
$homo.results

Call:
lm(formula = model, data = d[r, ])

Residuals:
     Min       1Q   Median       3Q      Max 
-2.68519 -0.81231  0.02665  0.91802  2.57805 

Coefficients: (3 not defined because of singularities)
                                    Estimate                Std. Error t value             Pr(>|t|)    
(Intercept)         3.1939003667681920006771  0.3442557280744077408130   9.278 < 0.0000000000000002 ***
pro                -0.1189237756765479658849  0.0576049610642938927918  -2.064             0.039111 *  
prot               -0.0205440318889985144846  0.0737831209770867801900  -0.278             0.780707    
com                -0.0601116922124375827052  0.0574362048649392498145  -1.047             0.295428    
mob                 0.0212990897335598138029  0.0570434154353457872899   0.373             0.708905    
eli.f               0.1861089916463025406568  0.0993180380879931795635   1.874             0.061104 .  
eli.c               0.0633960269238027368521  0.0972323879340618174583   0.652             0.514478    
authoritarian      -0.0222149366718971050250  0.0492837292065589210877  -0.451             0.652218    
ally               -0.0535675444225169120060  0.0491764430248387077182  -1.089             0.276165    
capabilities       -0.0634814619154143860991  0.0493738827755860615332  -1.286             0.198697    
salience            0.0278992189655086625377  0.0493746198576708802963   0.565             0.572106    
his                 0.0398164020110141070319  0.0492917318224725814479   0.808             0.419326    
pre.questions      -0.1193422778570502884588  0.0729869286501665104350  -1.635             0.102193    
asc.or              0.1459929157989800496686  0.0492804540083559630692   2.962             0.003090 ** 
partnerB           -0.1239107592647416961062  0.0744489738932680028549  -1.664             0.096206 .  
asc0.v2             0.3343648974817541863480  0.0354213287461584425131   9.440 < 0.0000000000000002 ***
na1.v2             -0.0610463042572439787414  0.0163375917092633791972  -3.737             0.000192 ***
na2.v2             -0.2674796509567944347019  0.0475276512429701758489  -5.628          0.000000021 ***
na3.v2              0.0424595572450069333459  0.0323934721534697434020   1.311             0.190105    
na2.v.dn           -0.0279548532925756668122  0.1443803401947073017375  -0.194             0.846495    
na3.v.dn           -0.1269749186890226644309  0.2298846594671758170048  -0.552             0.580780    
gender              0.0804144057985191756943  0.0528589191088673290841   1.521             0.128353    
educ               -0.0792635611665266220927  0.0431287941952504250143  -1.838             0.066246 .  
age                -0.0055666571755729095383  0.0025057930990079690069  -2.222             0.026436 *  
age.mTRUE          -0.1564512210378495582486  0.1928087413163772911862  -0.811             0.417221    
gender.mTRUE                              NA                        NA      NA                   NA    
educ.mTRUE                                NA                        NA      NA                   NA    
start.time.n        0.0000000198511292484103  0.0000001944105241184773   0.102             0.918681    
start.time.n2       0.0000000000007823143147  0.0000000000004760128176   1.643             0.100453    
start.time.n3      -0.0000000000000000006044  0.0000000000000000002570  -2.352             0.018773 *  
start.time.swdTRUE                        NA                        NA      NA                   NA    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.067 on 1868 degrees of freedom
  (1096 observations deleted due to missingness)
Multiple R-squared:  0.09598,	Adjusted R-squared:  0.08291 
F-statistic: 7.345 on 27 and 1868 DF,  p-value: < 0.00000000000000022



> results[2] 
$title
[1] "Inattentive-Hyp, Effect on Approval, Controlling Covariates, n=2992"


> results$fig.results

> m12_inattentive <- results[4]

> stargazerAD(c(m11_inattentive, m12_inattentive), title="Effect on Approval, Hypothetical (Inattentive respondents omitted)", filename=paste(fig.loc,title.f,"-table",".tex", sep=""))

% Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu
% Date and time: Wed, Feb 13, 2019 - 13:49:21
% Requires LaTeX packages: dcolumn 
\begin{table}[!htbp] \centering 
  \caption{Effect on Approval, Hypothetical (Inattentive respondents omitted)} 
  \label{} 
\begin{tabular}{@{\extracolsep{5pt}}lD{.}{.}{-3} D{.}{.}{-3} } 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
 & \multicolumn{2}{c}{\textit{Dependent variable:}} \\ 
\cline{2-3} 
\\[-1.8ex] & \multicolumn{2}{c}{asc} \\ 
\\[-1.8ex] & \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)}\\ 
\hline \\[-1.8ex] 
 pro & -0.080$ $(0.060) & -0.119^{*}$ $(0.058) \\ 
  prot & 0.015$ $(0.077) & -0.021$ $(0.074) \\ 
  com & -0.053$ $(0.060) & -0.060$ $(0.057) \\ 
  mob & -0.009$ $(0.059) & 0.021$ $(0.057) \\ 
  eli.f & 0.169$ $(0.103) & 0.186^{\dagger}$ $(0.099) \\ 
  eli.c & 0.068$ $(0.101) & 0.063$ $(0.097) \\ 
  authoritarian & -0.022$ $(0.051) & -0.022$ $(0.049) \\ 
  ally & -0.054$ $(0.051) & -0.054$ $(0.049) \\ 
  capabilities & -0.055$ $(0.051) & -0.063$ $(0.049) \\ 
  salience & 0.019$ $(0.051) & 0.028$ $(0.049) \\ 
  his & 0.053$ $(0.051) & 0.040$ $(0.049) \\ 
  pre.questions & -0.062$ $(0.059) & -0.119$ $(0.073) \\ 
  asc.or & 0.164^{**}$ $(0.051) & 0.146^{**}$ $(0.049) \\ 
  partnerB &  & -0.124^{\dagger}$ $(0.074) \\ 
  asc0.v2 &  & 0.334^{***}$ $(0.035) \\ 
  na1.v2 &  & -0.061^{***}$ $(0.016) \\ 
  na2.v2 &  & -0.267^{***}$ $(0.048) \\ 
  na3.v2 &  & 0.042$ $(0.032) \\ 
  na2.v.dn &  & -0.028$ $(0.144) \\ 
  na3.v.dn &  & -0.127$ $(0.230) \\ 
  gender &  & 0.080$ $(0.053) \\ 
  educ &  & -0.079^{\dagger}$ $(0.043) \\ 
  age &  & -0.006^{*}$ $(0.003) \\ 
  age.m &  & -0.156$ $(0.193) \\ 
  gender.m &  &  \\ 
  educ.m &  &  \\ 
  start.time.n &  & 0.00000$ $(0.00000) \\ 
  start.time.n2 &  & 0.000$ $(0.000) \\ 
  start.time.n3 &  & -0.000^{*}$ $(0.000) \\ 
  start.time.swd &  &  \\ 
  Constant & 2.850^{***}$ $(0.086) & 3.194^{***}$ $(0.344) \\ 
 \hline \\[-1.8ex] 
Observations & \multicolumn{1}{c}{1,896} & \multicolumn{1}{c}{1,896} \\ 
R$^{2}$ & \multicolumn{1}{c}{0.011} & \multicolumn{1}{c}{0.096} \\ 
Adjusted R$^{2}$ & \multicolumn{1}{c}{0.004} & \multicolumn{1}{c}{0.083} \\ 
Residual Std. Error & \multicolumn{1}{c}{1.111 (df = 1882)} & \multicolumn{1}{c}{1.067 (df = 1868)} \\ 
F Statistic & \multicolumn{1}{c}{1.623$^{\dagger}$ (df = 13; 1882)} & \multicolumn{1}{c}{7.345$^{***}$ (df = 27; 1868)} \\ 
\hline 
\hline \\[-1.8ex] 
\textit{Note:}  & \multicolumn{2}{r}{$^{\dagger} p<0.1$; $^{*} p<0.05$; $^{**} p<0.01$; $^{***} p<0.001$} \\ 
\end{tabular} 
\end{table} 
 [1] ""                                                                                                                                
 [2] "% Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu"                     
 [3] "% Date and time: Wed, Feb 13, 2019 - 13:49:22"                                                                                   
 [4] "% Requires LaTeX packages: dcolumn "                                                                                             
 [5] "\\begin{table}[!htbp] \\centering "                                                                                              
 [6] "  \\caption{Effect on Approval, Hypothetical (Inattentive respondents omitted)} "                                                
 [7] "  \\label{} "                                                                                                                    
 [8] "\\begin{tabular}{@{\\extracolsep{5pt}}lD{.}{.}{-3} D{.}{.}{-3} } "                                                               
 [9] "\\\\[-1.8ex]\\hline "                                                                                                            
[10] "\\hline \\\\[-1.8ex] "                                                                                                           
[11] " & \\multicolumn{2}{c}{\\textit{Dependent variable:}} \\\\ "                                                                     
[12] "\\cline{2-3} "                                                                                                                   
[13] "\\\\[-1.8ex] & \\multicolumn{2}{c}{asc} \\\\ "                                                                                   
[14] "\\\\[-1.8ex] & \\multicolumn{1}{c}{(1)} & \\multicolumn{1}{c}{(2)}\\\\ "                                                         
[15] "\\hline \\\\[-1.8ex] "                                                                                                           
[16] " pro & -0.080$ $(0.060) & -0.119^{*}$ $(0.058) \\\\ "                                                                            
[17] "  prot & 0.015$ $(0.077) & -0.021$ $(0.074) \\\\ "                                                                               
[18] "  com & -0.053$ $(0.060) & -0.060$ $(0.057) \\\\ "                                                                               
[19] "  mob & -0.009$ $(0.059) & 0.021$ $(0.057) \\\\ "                                                                                
[20] "  eli.f & 0.169$ $(0.103) & 0.186^{\\dagger}$ $(0.099) \\\\ "                                                                    
[21] "  eli.c & 0.068$ $(0.101) & 0.063$ $(0.097) \\\\ "                                                                               
[22] "  authoritarian & -0.022$ $(0.051) & -0.022$ $(0.049) \\\\ "                                                                     
[23] "  ally & -0.054$ $(0.051) & -0.054$ $(0.049) \\\\ "                                                                              
[24] "  capabilities & -0.055$ $(0.051) & -0.063$ $(0.049) \\\\ "                                                                      
[25] "  salience & 0.019$ $(0.051) & 0.028$ $(0.049) \\\\ "                                                                            
[26] "  his & 0.053$ $(0.051) & 0.040$ $(0.049) \\\\ "                                                                                 
[27] "  pre.questions & -0.062$ $(0.059) & -0.119$ $(0.073) \\\\ "                                                                     
[28] "  asc.or & 0.164^{**}$ $(0.051) & 0.146^{**}$ $(0.049) \\\\ "                                                                    
[29] "  partnerB &  & -0.124^{\\dagger}$ $(0.074) \\\\ "                                                                               
[30] "  asc0.v2 &  & 0.334^{***}$ $(0.035) \\\\ "                                                                                      
[31] "  na1.v2 &  & -0.061^{***}$ $(0.016) \\\\ "                                                                                      
[32] "  na2.v2 &  & -0.267^{***}$ $(0.048) \\\\ "                                                                                      
[33] "  na3.v2 &  & 0.042$ $(0.032) \\\\ "                                                                                             
[34] "  na2.v.dn &  & -0.028$ $(0.144) \\\\ "                                                                                          
[35] "  na3.v.dn &  & -0.127$ $(0.230) \\\\ "                                                                                          
[36] "  gender &  & 0.080$ $(0.053) \\\\ "                                                                                             
[37] "  educ &  & -0.079^{\\dagger}$ $(0.043) \\\\ "                                                                                   
[38] "  age &  & -0.006^{*}$ $(0.003) \\\\ "                                                                                           
[39] "  age.m &  & -0.156$ $(0.193) \\\\ "                                                                                             
[40] "  gender.m &  &  \\\\ "                                                                                                          
[41] "  educ.m &  &  \\\\ "                                                                                                            
[42] "  start.time.n &  & 0.00000$ $(0.00000) \\\\ "                                                                                   
[43] "  start.time.n2 &  & 0.000$ $(0.000) \\\\ "                                                                                      
[44] "  start.time.n3 &  & -0.000^{*}$ $(0.000) \\\\ "                                                                                 
[45] "  start.time.swd &  &  \\\\ "                                                                                                    
[46] "  Constant & 2.850^{***}$ $(0.086) & 3.194^{***}$ $(0.344) \\\\ "                                                                
[47] " \\hline \\\\[-1.8ex] "                                                                                                          
[48] "Observations & \\multicolumn{1}{c}{1,896} & \\multicolumn{1}{c}{1,896} \\\\ "                                                    
[49] "R$^{2}$ & \\multicolumn{1}{c}{0.011} & \\multicolumn{1}{c}{0.096} \\\\ "                                                         
[50] "Adjusted R$^{2}$ & \\multicolumn{1}{c}{0.004} & \\multicolumn{1}{c}{0.083} \\\\ "                                                
[51] "Residual Std. Error & \\multicolumn{1}{c}{1.111 (df = 1882)} & \\multicolumn{1}{c}{1.067 (df = 1868)} \\\\ "                     
[52] "F Statistic & \\multicolumn{1}{c}{1.623$^{\\dagger}$ (df = 13; 1882)} & \\multicolumn{1}{c}{7.345$^{***}$ (df = 27; 1868)} \\\\ "
[53] "\\hline "                                                                                                                        
[54] "\\hline \\\\[-1.8ex] "                                                                                                           
[55] "\\textit{Note:}  & \\multicolumn{2}{r}{$^{\\dagger} p<0.1$; $^{*} p<0.05$; $^{**} p<0.01$; $^{***} p<0.001$} \\\\ "              
[56] "\\end{tabular} "                                                                                                                 
[57] "\\end{table} "                                                                                                                   

> ##analysis of inattention distribution
> r <- !is.na(d$asc) & rb

> type <- "Random-Inattentive-Hyp"

> outcome <- "Attentiveness"

> cont <- ""

> title.w <- paste(type, ", Effect on ", outcome, cont, sep="")

> title.f <- paste(type, "-", outcome, cont, sep="")

> #coefficients.list<- c("his", "pro", "prot", "com", "mob", "eli.f", "eli.c")
> coefficients.list<- c("his", "pro", "com", "mob", "eli.f", "eli.c")

> model <- att ~ pro + prot + com + mob + eli.f + eli.c + 
+   authoritarian + ally + capabilities + salience + his +
+   pre.questions + asc.or 

> results <- results.fun(data=d, r=r, model=model, title.w=title.w, fig.loc=fig.loc, coefficients=coefficients.list, innerCI.n=innerCI.n, outerCI.n=outerCI.n, w=w, h=h)

> m31_inattentive <- results[4]

> r <- !is.na(d$asc) & rb

> type <- "Random-Inattentive-Hyp"

> outcome <- "Attentiveness"

> cont <- "Covariates"

> title.w <- paste(type, ", Effect on ", outcome, ", Controlling ", cont, sep="")

> title.f <- paste(type, "-", outcome, cont, sep="")

> #coefficients.list<- c("his", "pro", "prot", "com", "mob", "eli.f", "eli.c")
> coefficients.list<- c("his", "pro", "com", "mob", "eli.f", "eli.c")

> model <- att ~ pro + prot + com + mob + eli.f + eli.c + 
+   authoritarian + ally + capabilities + salience + his +
+   pre.questions + asc.or +  partner + asc.or + asc0.v2  +
+   na1.v2 + na2.v2 + na3.v2 + na2.v.dn + na3.v.dn + gender + educ + age +
+   start.time.n + start.time.n2 + start.time.n3 + start.time.swd 

> results <- results.fun(data=d, r=r, model=model, title.w=title.w, fig.loc=fig.loc, coefficients=coefficients.list, innerCI.n=innerCI.n, outerCI.n=outerCI.n, w=w, h=h)

> results[1]
$homo.results

Call:
lm(formula = model, data = d[r, ])

Residuals:
    Min      1Q  Median      3Q     Max 
-0.9371 -0.1516 -0.0257  0.1134  1.6026 

Coefficients: (1 not defined because of singularities)
                                     Estimate                 Std. Error t value             Pr(>|t|)    
(Intercept)        -0.96245703453574982244589  0.04737454920168231164990 -20.316 < 0.0000000000000002 ***
pro                -0.00616638391762235234250  0.00964685968371024535339  -0.639               0.5227    
prot                0.00069294229724634428570  0.01237494698475676002669   0.056               0.9553    
com                 0.00622476107194724990329  0.00965555086423258018824   0.645               0.5192    
mob                 0.00749555702438841047613  0.00972935027444127992213   0.770               0.4411    
eli.f              -0.00456474987079971954856  0.01583974601240361115839  -0.288               0.7732    
eli.c               0.01517610856166701736869  0.01580158064382368443557   0.960               0.3369    
authoritarian       0.00301328241070319708533  0.00822170359769924460891   0.367               0.7140    
ally                0.00944175533470638199407  0.00821027834126758331024   1.150               0.2502    
capabilities       -0.00343581697561929494400  0.00823127974247898214211  -0.417               0.6764    
salience            0.00410332863214542611918  0.00823713726547959344815   0.498               0.6184    
his                -0.00099324111556556488913  0.00822846480108758819572  -0.121               0.9039    
pre.questions       0.00271580396728951945634  0.01231834400179133461040   0.220               0.8255    
asc.or             -0.00657618888940628490425  0.00822120222146404538988  -0.800               0.4238    
partnerB           -0.02642691208724058313240  0.01228219402706414234427  -2.152               0.0315 *  
asc0.v2            -0.00306194925710227177154  0.00578507603193435110400  -0.529               0.5966    
na1.v2              0.01242068362499071723648  0.00257713276097011698834   4.820           0.00000151 ***
na2.v2              0.00478869649431811882784  0.00757504458785172168911   0.632               0.5273    
na3.v2              0.00619003099989229917804  0.00521399735743438823982   1.187               0.2352    
na2.v.dn            0.03896841989153174840022  0.02193696099270952756810   1.776               0.0758 .  
na3.v.dn           -0.05437745170404967298694  0.03106858181389978573739  -1.750               0.0802 .  
gender             -0.14931435755646940699570  0.01006803675302308902217 -14.831 < 0.0000000000000002 ***
educ                0.33432735208648489688699  0.00476675628947836882432  70.137 < 0.0000000000000002 ***
age                 0.00449619386102767353008  0.00049752352133031435381   9.037 < 0.0000000000000002 ***
start.time.n       -0.00000002463514131165772  0.00000003545354692375712  -0.695               0.4872    
start.time.n2       0.00000000000014422861438  0.00000000000008333228043   1.731               0.0836 .  
start.time.n3      -0.00000000000000000008614  0.00000000000000000004410  -1.953               0.0509 .  
start.time.swdTRUE                         NA                         NA      NA                   NA    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.2241 on 2965 degrees of freedom
Multiple R-squared:  0.7683,	Adjusted R-squared:  0.7662 
F-statistic: 378.1 on 26 and 2965 DF,  p-value: < 0.00000000000000022



> results[2] 
$title
[1] "Random-Inattentive-Hyp, Effect on Attentiveness, Controlling Covariates, n=2992"


> results$fig.results

> m32_inattentive <- results[4]

> stargazerAD(c(m31_inattentive), title="Effect on Attentiveness, Hypothetical", filename=paste(fig.loc,title.f,"-table",".tex", sep=""))

% Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu
% Date and time: Wed, Feb 13, 2019 - 13:49:22
% Requires LaTeX packages: dcolumn 
\begin{table}[!htbp] \centering 
  \caption{Effect on Attentiveness, Hypothetical} 
  \label{} 
\begin{tabular}{@{\extracolsep{5pt}}lD{.}{.}{-3} } 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
 & \multicolumn{1}{c}{\textit{Dependent variable:}} \\ 
\cline{2-2} 
\\[-1.8ex] & \multicolumn{1}{c}{att} \\ 
\hline \\[-1.8ex] 
 pro & 0.005$ $(0.020) \\ 
  prot & 0.008$ $(0.026) \\ 
  com & 0.032$ $(0.020) \\ 
  mob & 0.059^{**}$ $(0.020) \\ 
  eli.f & -0.049$ $(0.033) \\ 
  eli.c & -0.042$ $(0.033) \\ 
  authoritarian & -0.007$ $(0.017) \\ 
  ally & 0.010$ $(0.017) \\ 
  capabilities & -0.002$ $(0.017) \\ 
  salience & -0.0001$ $(0.017) \\ 
  his & -0.029^{\dagger}$ $(0.017) \\ 
  pre.questions & -0.033^{\dagger}$ $(0.020) \\ 
  asc.or & 0.0002$ $(0.017) \\ 
  Constant & 0.709^{***}$ $(0.029) \\ 
 \hline \\[-1.8ex] 
Observations & \multicolumn{1}{c}{2,992} \\ 
R$^{2}$ & \multicolumn{1}{c}{0.008} \\ 
Adjusted R$^{2}$ & \multicolumn{1}{c}{0.003} \\ 
Residual Std. Error & \multicolumn{1}{c}{0.463 (df = 2978)} \\ 
F Statistic & \multicolumn{1}{c}{1.790$^{*}$ (df = 13; 2978)} \\ 
\hline 
\hline \\[-1.8ex] 
\textit{Note:}  & \multicolumn{1}{r}{$^{\dagger} p<0.1$; $^{*} p<0.05$; $^{**} p<0.01$; $^{***} p<0.001$} \\ 
\end{tabular} 
\end{table} 
 [1] ""                                                                                                                  
 [2] "% Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu"       
 [3] "% Date and time: Wed, Feb 13, 2019 - 13:49:22"                                                                     
 [4] "% Requires LaTeX packages: dcolumn "                                                                               
 [5] "\\begin{table}[!htbp] \\centering "                                                                                
 [6] "  \\caption{Effect on Attentiveness, Hypothetical} "                                                               
 [7] "  \\label{} "                                                                                                      
 [8] "\\begin{tabular}{@{\\extracolsep{5pt}}lD{.}{.}{-3} } "                                                             
 [9] "\\\\[-1.8ex]\\hline "                                                                                              
[10] "\\hline \\\\[-1.8ex] "                                                                                             
[11] " & \\multicolumn{1}{c}{\\textit{Dependent variable:}} \\\\ "                                                       
[12] "\\cline{2-2} "                                                                                                     
[13] "\\\\[-1.8ex] & \\multicolumn{1}{c}{att} \\\\ "                                                                     
[14] "\\hline \\\\[-1.8ex] "                                                                                             
[15] " pro & 0.005$ $(0.020) \\\\ "                                                                                      
[16] "  prot & 0.008$ $(0.026) \\\\ "                                                                                    
[17] "  com & 0.032$ $(0.020) \\\\ "                                                                                     
[18] "  mob & 0.059^{**}$ $(0.020) \\\\ "                                                                                
[19] "  eli.f & -0.049$ $(0.033) \\\\ "                                                                                  
[20] "  eli.c & -0.042$ $(0.033) \\\\ "                                                                                  
[21] "  authoritarian & -0.007$ $(0.017) \\\\ "                                                                          
[22] "  ally & 0.010$ $(0.017) \\\\ "                                                                                    
[23] "  capabilities & -0.002$ $(0.017) \\\\ "                                                                           
[24] "  salience & -0.0001$ $(0.017) \\\\ "                                                                              
[25] "  his & -0.029^{\\dagger}$ $(0.017) \\\\ "                                                                         
[26] "  pre.questions & -0.033^{\\dagger}$ $(0.020) \\\\ "                                                               
[27] "  asc.or & 0.0002$ $(0.017) \\\\ "                                                                                 
[28] "  Constant & 0.709^{***}$ $(0.029) \\\\ "                                                                          
[29] " \\hline \\\\[-1.8ex] "                                                                                            
[30] "Observations & \\multicolumn{1}{c}{2,992} \\\\ "                                                                   
[31] "R$^{2}$ & \\multicolumn{1}{c}{0.008} \\\\ "                                                                        
[32] "Adjusted R$^{2}$ & \\multicolumn{1}{c}{0.003} \\\\ "                                                               
[33] "Residual Std. Error & \\multicolumn{1}{c}{0.463 (df = 2978)} \\\\ "                                                
[34] "F Statistic & \\multicolumn{1}{c}{1.790$^{*}$ (df = 13; 2978)} \\\\ "                                              
[35] "\\hline "                                                                                                          
[36] "\\hline \\\\[-1.8ex] "                                                                                             
[37] "\\textit{Note:}  & \\multicolumn{1}{r}{$^{\\dagger} p<0.1$; $^{*} p<0.05$; $^{**} p<0.01$; $^{***} p<0.001$} \\\\ "
[38] "\\end{tabular} "                                                                                                   
[39] "\\end{table} "                                                                                                     

> #Checking if provocation or statement of commitment interacts with eli.f or eli.c.
> 
> model <- asc ~ pro + prot + com + mob + eli.f + eli.c + com*eli.f + com*eli.c + pro*eli.f + pro*eli.c +
+   authoritarian + ally + capabilities + salience + his +
+   pre.questions + asc.or +  partner + asc.or + asc0.v2  +
+   na1.v2 + na2.v2 + na3.v2 + na2.v.dn + na3.v.dn + gender + educ + age + age.m + gender.m + educ.m + 
+   start.time.n + start.time.n2 + start.time.n3 + start.time.swd 

> coefplot(lm(model, data=d[r,]), title=title.w, 
+          intercept=FALSE, lwdOuter=0.5, innerCI=innerCI.n, outerCI= outerCI.n, data=d) + theme_bw()

> #Results: Same as above.
> 
> 
> r <- !is.na(d$asc) & rb

> title.w <- "Hyp, Effect on Resolve"

> type <- "Hyp"

> outcome <- "Resolve"

> cont <- ""

> title.w <- paste(type, ", Effect on ", outcome, cont, sep="")

> title.f <- paste(type, "-", outcome, cont, sep="")

> coefficients.list<- c("his", "pro", "com", "mob", "eli.f", "eli.c")

> model <- rac ~ pro + prot + com + mob + eli.f + eli.c + 
+   authoritarian + ally + capabilities + salience + his +
+   pre.questions + rac.or

> results <- results.fun(data=d, r=r, model=model, title.w=title.w, fig.loc=fig.loc, coefficients=coefficients.list, innerCI.n=innerCI.n, outerCI.n=outerCI.n, w=w, h=h)

> results[1]
$homo.results

Call:
lm(formula = model, data = d[r, ])

Residuals:
    Min      1Q  Median      3Q     Max 
-63.163 -12.420   0.604  17.143  46.735 

Coefficients:
              Estimate Std. Error t value             Pr(>|t|)    
(Intercept)   54.29440    1.44853  37.483 < 0.0000000000000002 ***
pro            0.83791    0.99935   0.838              0.40184    
prot          -0.12871    1.27786  -0.101              0.91977    
com            0.23663    0.99843   0.237              0.81267    
mob            1.95840    1.00563   1.947              0.05158 .  
eli.f          0.04484    1.63736   0.027              0.97816    
eli.c         -0.72988    1.63304  -0.447              0.65495    
authoritarian -0.63390    0.85187  -0.744              0.45686    
ally           1.01261    0.85150   1.189              0.23446    
capabilities   1.29701    0.85263   1.521              0.12832    
salience       1.01566    0.85373   1.190              0.23427    
his           -0.39556    0.85169  -0.464              0.64236    
pre.questions  3.18072    1.00419   3.167              0.00155 ** 
rac.or         0.97490    0.85183   1.144              0.25252    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 22.96 on 2899 degrees of freedom
  (79 observations deleted due to missingness)
Multiple R-squared:  0.007444,	Adjusted R-squared:  0.002993 
F-statistic: 1.673 on 13 and 2899 DF,  p-value: 0.06014



> results[2] 
$title
[1] "Hyp, Effect on Resolve, n=2992"


> results$fig.results

> coefplot(lm(model, data=d[r,]), title=title.w, 
+          intercept=FALSE, lwdOuter=0.5, innerCI=innerCI.n, outerCI= outerCI.n, data=d) + theme_bw()

> pdf(paste(fig.loc,title.f,".pdf", sep=""), width=w, height=h)

> results$fig.results

> dev.off()
RStudioGD 
        2 

> #Interactions with elite cues?
> model <- rac ~ pro + prot + com + mob + eli.f + eli.c + com*eli.f + com*eli.c + pro*eli.f + pro*eli.c +
+   authoritarian + ally + capabilities + salience + his +
+   pre.questions + rac.or

> coefplot(lm(model, data=d[r,]), title=title.w, 
+          intercept=FALSE, lwdOuter=0.5, innerCI=innerCI.n, outerCI= outerCI.n, data=d) + theme_bw()

> #Provocation (maybe) positively interacts with elite cues for resolve. So provocation now has no main effect, but especially operates after elite cues. Why?  I don't know. Maybe the elite cues work when honor is not at stake. But when honor is at stake, they seem like wimply excuses. The positive interaction is stronger for elite cue costs. And similarly, a provocation can be more easily swallowed if you don't make excuses, but if you do it is perceived as worse. ?
> 
> #reduce resolve for those motivated by  
> 
> 
> pro.results <- rbind(pro.results, coef(summary(results$model))["pro",])

> row.names(pro.results)[length(pro.results[,1])] <- "resolve"

> toprint <- paste("p_{+}=",round(pro.results[3,4]/2,3),  sep="")

> write(toprint, file=paste(fig.loc,type,outcome,"p",".tex", sep=""))

> statement.results <- rbind(statement.results, coef(summary(results$model))[c("com","mob", "his", "eli.f","eli.c"),])

> ln <- length(statement.results[,1])-l1

> r <- (l1+1):(l1+ln)

> row.names(statement.results)[r] <- paste(row.names(statement.results)[r], rep(", ", ln), c(rep("resolve",ln)), sep="")

> r <- !is.na(d$asc) & rb

> title.w <- "Hyp, Effect on Resolve, Controlling Covariates"

> type <- "Hyp"

> outcome <- "Resolve"

> cont <- "Covariates"

> title.w <- paste(type, ", Effect on ", outcome, ", Controlling ", cont, sep="")

> title.f <- paste(type, "-", outcome, cont, sep="")

> #coefficients.list<- c("his", "pro", "prot", "com", "mob", "eli.f", "eli.c")
> coefficients.list<- c("his", "pro", "com", "eli.f", "eli.c")

> model <- rac ~ pro + prot + com + mob + eli.f + eli.c + 
+   authoritarian + ally + capabilities + salience + his +
+   pre.questions + rac.or +  partner + asc.or + asc0.v2  +
+   na1.v2 + na2.v2 + na3.v2 + na2.v.dn + na3.v.dn + gender + educ + age + age.m + gender.m + educ.m + 
+   start.time.n + start.time.n2 + start.time.n3 + start.time.swd 

> results <- results.fun(data=d, r=r, model=model, title.w=title.w, fig.loc=fig.loc, coefficients=coefficients.list, innerCI.n=innerCI.n, outerCI.n=outerCI.n, w=w, h=h)

> results[1]
$homo.results

Call:
lm(formula = model, data = d[r, ])

Residuals:
   Min     1Q Median     3Q    Max 
-68.61 -13.55   0.95  15.83  67.70 

Coefficients: (3 not defined because of singularities)
                                  Estimate              Std. Error t value             Pr(>|t|)    
(Intercept)        19.46065904358049891698  6.31442501378626008801   3.082             0.002076 ** 
pro                 0.79963484896854741812  0.97225371599792653754   0.822             0.410886    
prot                0.03063290247168037189  1.24164988165644785134   0.025             0.980319    
com                 0.49645902369144595534  0.97061238852402864641   0.511             0.609047    
mob                 2.05989582553539429810  0.97866777245915914651   2.105             0.035395 *  
eli.f              -0.32982631728819122863  1.59188026945408767077  -0.207             0.835874    
eli.c              -0.61570543196600624469  1.58970068078864223970  -0.387             0.698556    
authoritarian      -0.76645802073625246553  0.82833977472277653398  -0.925             0.354890    
ally                0.87784040084154379979  0.82680758733844994524   1.062             0.288450    
capabilities        1.89165826163420636163  0.82896491428746388319   2.282             0.022565 *  
salience            0.71911596485186424221  0.82968059896174184420   0.867             0.386158    
his                -0.18866581602779827764  0.82913953367868453714  -0.228             0.820017    
pre.questions       3.52453677829362765905  1.24140481784741374405   2.839             0.004555 ** 
rac.or              1.14255882657629204147  0.82806766063963599400   1.380             0.167759    
partnerB            1.80183331447206462883  1.23611365197896239110   1.458             0.145043    
asc.or              0.79258438953988874509  0.82802571069115937785   0.957             0.338548    
asc0.v2            -0.58699370494542757459  0.58271973327488590932  -1.007             0.313859    
na1.v2              3.00728428175579720616  0.26073909816711304810  11.534 < 0.0000000000000002 ***
na2.v2              1.26333223560996188439  0.76348260657873423529   1.655             0.098095 .  
na3.v2             -1.14144227971161993374  0.52325674052642279221  -2.181             0.029233 *  
na2.v.dn           -1.45547084837575968486  2.25207046078111350340  -0.646             0.518149    
na3.v.dn           -4.22752342130324887393  3.22519971879379285795  -1.311             0.190037    
gender             -1.99580568232522992389  1.05564080798141457507  -1.891             0.058777 .  
educ                1.30200263036724983579  0.87050965395044399564   1.496             0.134847    
age                 0.17535777275821401444  0.05032946689581845739   3.484             0.000501 ***
age.mTRUE           8.06873968050591905410  2.09675278088432204271   3.848             0.000122 ***
gender.mTRUE                            NA                      NA      NA                   NA    
educ.mTRUE                              NA                      NA      NA                   NA    
start.time.n        0.00000813632887665269  0.00000355263159568334   2.290             0.022080 *  
start.time.n2      -0.00000000002132533590  0.00000000000837668292  -2.546             0.010954 *  
start.time.n3       0.00000000000000001113  0.00000000000000000444   2.507             0.012240 *  
start.time.swdTRUE                      NA                      NA      NA                   NA    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 22.27 on 2884 degrees of freedom
  (79 observations deleted due to missingness)
Multiple R-squared:  0.07084,	Adjusted R-squared:  0.06181 
F-statistic: 7.852 on 28 and 2884 DF,  p-value: < 0.00000000000000022



> results[2] 
$title
[1] "Hyp, Effect on Resolve, Controlling Covariates, n=2992"


> results$fig.results

> coefplot(lm(model, data=d[r,]), title=title.w, 
+          intercept=FALSE, lwdOuter=0.5, innerCI=innerCI.n, outerCI= outerCI.n, data=d) + theme_bw()

> pdf(paste(fig.loc,title.f,".pdf", sep=""), width=w, height=h)

> results$fig.results

> dev.off()
RStudioGD 
        2 

> r <- !is.na(d$asc) & rb

> #Interactions with elite cues?
> model <- rac ~ pro + prot + com + mob + eli.f + eli.c + com*eli.f + com*eli.c + pro*eli.f + pro*eli.c +
+   authoritarian + ally + capabilities + salience + his +
+   pre.questions + rac.or +  partner + asc.or + asc0.v2  +
+   na1.v2 + na2.v2 + na3.v2 + na2.v.dn + na3.v.dn + gender + educ + age + age.m + gender.m + educ.m + 
+   start.time.n + start.time.n2 + start.time.n3 + start.time.swd 

> coefplot(lm(model, data=d[r,]), title=title.w, 
+          intercept=FALSE, lwdOuter=0.5, innerCI=innerCI.n, outerCI= outerCI.n, data=d) + theme_bw()

> #Similar results. 
> 
> 
> 
> pro.results <- rbind(pro.results, coef(summary(results$model))["pro",])

> row.names(pro.results)[length(pro.results[,1])] <- "resolve, cov"

> statement.results <- rbind(statement.results, coef(summary(results$model))[c("com", "mob", "his", "eli.f","eli.c"),])

> l1 <- ln+l1

> ln <- length(statement.results[,1])-l1

> r <- (l1+1):(l1+ln)

> row.names(statement.results)[r] <- paste(row.names(statement.results)[r], rep(", ", ln), c(rep("resolve, cov",ln)), sep="")

> r <- !is.na(d$asc) & rb

> title.w <- "Hyp, Effect on Resolve2"

> type <- "Hyp"

> outcome <- "Resolve2"

> cont <- ""

> title.w <- paste(type, ", Effect on ", outcome, cont, sep="")

> title.f <- paste(type, "-", outcome, cont, sep="")

> #coefficients.list<- c("his", "pro", "prot", "com", "mob", "eli.f", "eli.c")
> coefficients.list<- c("his", "pro", "com", "eli.f", "eli.c")

> model <- ra3c ~ pro + prot + com + mob + eli.f + eli.c + 
+   authoritarian + ally + capabilities + salience + his +
+   pre.questions 

> results <- results.fun(data=d, r=r, model=model, title.w=title.w, fig.loc=fig.loc, coefficients=coefficients.list, innerCI.n=innerCI.n, outerCI.n=outerCI.n, w=w, h=h)

> results[1]
$homo.results

Call:
lm(formula = model, data = d[r, ])

Residuals:
     Min       1Q   Median       3Q      Max 
-2.16001 -0.10821  0.01737  0.18305  1.14027 

Coefficients:
              Estimate Std. Error t value            Pr(>|t|)    
(Intercept)    2.89724    0.05822  49.763 <0.0000000000000002 ***
pro            0.01828    0.03782   0.483              0.6289    
prot          -0.06176    0.04881  -1.265              0.2059    
com            0.04495    0.03838   1.171              0.2416    
mob            0.07547    0.03844   1.963              0.0497 *  
eli.f          0.05190    0.06213   0.835              0.4036    
eli.c          0.05525    0.06175   0.895              0.3710    
authoritarian  0.05206    0.03229   1.612              0.1070    
ally           0.02455    0.03232   0.760              0.4475    
capabilities   0.04629    0.03233   1.432              0.1523    
salience       0.05135    0.03238   1.586              0.1130    
his           -0.01898    0.03228  -0.588              0.5565    
pre.questions -0.01853    0.04593  -0.403              0.6867    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.749 on 2144 degrees of freedom
  (835 observations deleted due to missingness)
Multiple R-squared:  0.007508,	Adjusted R-squared:  0.001953 
F-statistic: 1.352 on 12 and 2144 DF,  p-value: 0.1824



> results[2] 
$title
[1] "Hyp, Effect on Resolve2, n=2992"


> results$fig.results

> coefplot(lm(model, data=d[r,]), title=title.w, 
+          intercept=FALSE, lwdOuter=0.5, innerCI=innerCI.n, outerCI= outerCI.n, data=d) + theme_bw()

> pdf(paste(fig.loc,title.f,".pdf", sep=""), width=w, height=h)

> results$fig.results

> dev.off()
RStudioGD 
        2 

> r <- !is.na(d$asc) & rb

> title.w <- "Hyp, Effect on Resolve2, Controlling Covariates"

> type <- "Hyp"

> outcome <- "Resolve2"

> cont <- "Covariates"

> title.w <- paste(type, ", Effect on ", outcome, ", Controlling ", cont, sep="")

> title.f <- paste(type, "-", outcome, cont, sep="")

> #coefficients.list<- c("his", "pro", "prot", "com", "mob", "eli.f", "eli.c")
> coefficients.list<- c("his", "pro", "com", "eli.f", "eli.c")

> model <- ra3c ~ pro + prot + com + mob + eli.f + eli.c + 
+   authoritarian + ally + capabilities + salience + his +
+   pre.questions +  partner + asc.or + asc0.v2  +
+   na1.v2 + na2.v2 + na3.v2 + na2.v.dn + na3.v.dn + gender + educ + age + age.m + gender.m + educ.m + 
+   start.time.n + start.time.n2 + start.time.n3 + start.time.swd 

> results <- results.fun(data=d, r=r, model=model, title.w=title.w, fig.loc=fig.loc, coefficients=coefficients.list, innerCI.n=innerCI.n, outerCI.n=outerCI.n, w=w, h=h)

> results[1]
$homo.results

Call:
lm(formula = model, data = d[r, ])

Residuals:
     Min       1Q   Median       3Q      Max 
-2.19935 -0.33899 -0.00627  0.56652  1.81491 

Coefficients: (3 not defined because of singularities)
                                    Estimate                Std. Error t value             Pr(>|t|)    
(Intercept)         1.7558936222539460736414  0.2642180557641140570269   6.646      0.0000000000382 ***
pro                 0.0281884357589345935224  0.0363145220357564621483   0.776             0.437699    
prot               -0.0641392595187829095416  0.0467979487008938072057  -1.371             0.170658    
com                 0.0454513049089198123420  0.0369015123838809314116   1.232             0.218200    
mob                 0.0560067829196790115120  0.0368909785472587570254   1.518             0.129120    
eli.f               0.0690475189698208785538  0.0596023037810416295157   1.158             0.246802    
eli.c               0.0803711731863655243213  0.0593074268768325335577   1.355             0.175510    
authoritarian       0.0498335259191790627686  0.0310091455348354069765   1.607             0.108190    
ally                0.0213941194913000246047  0.0309553159868020087708   0.691             0.489560    
capabilities        0.0564425587220104899022  0.0309577531153494636684   1.823             0.068411 .  
salience            0.0515412780785009863593  0.0310832822286656526578   1.658             0.097431 .  
his                 0.0070853450715941852789  0.0309907758486248630092   0.229             0.819180    
pre.questions      -0.0449036120007541839083  0.0560297623564350102954  -0.801             0.422975    
partnerB            0.1174937249136829287011  0.0419037211527404016009   2.804             0.005095 ** 
asc.or              0.0086014778843517304685  0.0310101770754187475165   0.277             0.781518    
asc0.v2            -0.0305280260581213547244  0.0205508984474077477378  -1.485             0.137564    
na1.v2              0.0860527748644712708881  0.0093362022913527735468   9.217 < 0.0000000000000002 ***
na2.v2              0.1021347919556870459390  0.0272699522597451143868   3.745             0.000185 ***
na3.v2              0.0259896071212242611714  0.0185056664331843499782   1.404             0.160342    
na2.v.dn            0.0374675365711841235061  0.0794114038170985192533   0.472             0.637107    
na3.v.dn            0.1248050814158005034082  0.1107942261184783200312   1.126             0.260099    
gender              0.0015066023238645130135  0.0397355785532810534821   0.038             0.969758    
educ                0.0425512462040695121912  0.0320365880275971445790   1.328             0.184252    
age                 0.0040323311910674154712  0.0018394692940736682377   2.192             0.028479 *  
age.mTRUE          -0.1096768383082959291697  0.0775985548033572003490  -1.413             0.157688    
gender.mTRUE                              NA                        NA      NA                   NA    
educ.mTRUE                                NA                        NA      NA                   NA    
start.time.n       -0.0000006197529714464213  0.0000006928395946666210  -0.895             0.371149    
start.time.n2       0.0000000000008218675925  0.0000000000010332820428   0.795             0.426472    
start.time.n3      -0.0000000000000000003279  0.0000000000000000004375  -0.750             0.453637    
start.time.swdTRUE                        NA                        NA      NA                   NA    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.7163 on 2129 degrees of freedom
  (835 observations deleted due to missingness)
Multiple R-squared:  0.09848,	Adjusted R-squared:  0.08704 
F-statistic: 8.613 on 27 and 2129 DF,  p-value: < 0.00000000000000022



> results[2]
$title
[1] "Hyp, Effect on Resolve2, Controlling Covariates, n=2992"


> results$fig.results

> coefplot(lm(model, data=d[r,]), title=title.w, 
+          intercept=FALSE, lwdOuter=0.5, innerCI=innerCI.n, outerCI= outerCI.n, data=d) + theme_bw()

> pdf(paste(fig.loc,title.f,".pdf", sep=""), width=w, height=h)

> results$fig.results

> dev.off()
RStudioGD 
        2 

> pvalues <- -1

> pdf(paste(fig.loc,"Hyp-Approval(Pre)-Histogram",".pdf", sep=""), width=w, height=h*1.6)

> par(mar=c(3.1,4.1,4,2.1))

> hist(d$asc0, main="Approval (Pre) in Hypothetical", breaks=seq(0.5, 5.5, 1), freq=FALSE, labels=TRUE, col="blue", xaxt='n', xlab="", ylim=c(0,0.5))

> axis(side=1, at=c(1, 3, 5), labels=c("Strongly \n disapprove", "Neither approve \n nor disapprove", "Strongly \n approve"))

> dev.off()
RStudioGD 
        2 

> pdf(paste(fig.loc,"Hyp-Approval(Post)-Histogram",".pdf", sep=""), width=w, height=h*1.6)

> par(mar=c(3.1,4.1,4,2.1))

> hist(d$asc, main="Approval (Post) in Hypothetical", breaks=seq(0.5, 5.5, 1), freq=FALSE, labels=TRUE, col="blue", xaxt='n', xlab="", ylim=c(0,0.5))

> axis(side=1, at=c(1, 3, 5), labels=c("Strongly \n disapprove", "Neither approve \n nor disapprove", "Strongly \n approve"))

> dev.off()
RStudioGD 
        2 

> pro.results <- as.data.frame(pro.results)

> pro.results$names <- as.factor(row.names(pro.results))

> pro.results$names2 <- as.factor(c("No Covariates", "Covariates", "No Covariates", "Covariates"))

> pro.results$dv <- c(0,0,1,1)

> names(pro.results) <- c("est", "se", "t", "p", "names", "names2", "dv")

> pro.results
                      est         se          t          p         names        names2 dv
approval      -0.09045405 0.04702250 -1.9236334 0.05449577      approval No Covariates  0
approval, cov -0.10802329 0.04459621 -2.4222525 0.01548423 approval, cov    Covariates  0
resolve        0.83791451 0.99935284  0.8384571 0.40184314       resolve No Covariates  1
resolve, cov   0.79963485 0.97225372  0.8224549 0.41088603  resolve, cov    Covariates  1

> statement.results <- as.data.frame(statement.results)

> statement.results$names <- as.factor(row.names(statement.results))

> statement.results$names2 <- as.factor(rep(c(rep("No Covariates",5),rep("Covariates",5)),2))

> statement.results$names3 <- as.factor(rep(c("Explicit threat", "Mobilization", "Nationalist History", "Biding Time", "Cost of War"),4))

> statement.results$dv <- c(rep(0,10), rep(1,10))

> names(statement.results) <- c("est", "se", "t", "p", "names", "names2","names3", "dv")

> statement.results$names4 <- paste(statement.results$names3, "\n ", statement.results$names2, sep="")

> statement.results
                             est         se           t          p                names        names2              names3 dv
com, approval        -0.06941515 0.04710294 -1.47369047 0.14067064        com, approval No Covariates     Explicit threat  0
mob, approval         0.00756145 0.04737921  0.15959428 0.87321151        mob, approval No Covariates        Mobilization  0
his, approval         0.04340482 0.04008756  1.08275028 0.27900694        his, approval No Covariates Nationalist History  0
eli.f, approval       0.12030429 0.07719849  1.55837631 0.11925033      eli.f, approval No Covariates         Biding Time  0
eli.c, approval       0.03993247 0.07699994  0.51860391 0.60407551      eli.c, approval No Covariates         Cost of War  0
com, approval, cov   -0.05585939 0.04463278 -1.25153261 0.21083899   com, approval, cov    Covariates     Explicit threat  0
mob, approval, cov    0.05272816 0.04496374  1.17268189 0.24101763   mob, approval, cov    Covariates        Mobilization  0
his, approval, cov    0.03040867 0.03802467  0.79970882 0.42394361   his, approval, cov    Covariates Nationalist History  0
eli.f, approval, cov  0.09329032 0.07320328  1.27440073 0.20262134 eli.f, approval, cov    Covariates         Biding Time  0
eli.c, approval, cov  0.02578704 0.07301975  0.35315160 0.72399990 eli.c, approval, cov    Covariates         Cost of War  0
com, resolve          0.23663200 0.99842943  0.23700423 0.81267025         com, resolve No Covariates     Explicit threat  1
mob, resolve          1.95839557 1.00562805  1.94743531 0.05157899         mob, resolve No Covariates        Mobilization  1
his, resolve         -0.39556342 0.85168508 -0.46444799 0.64236169         his, resolve No Covariates Nationalist History  1
eli.f, resolve        0.04483571 1.63735912  0.02738294 0.97815619       eli.f, resolve No Covariates         Biding Time  1
eli.c, resolve       -0.72987945 1.63304405 -0.44694413 0.65494879       eli.c, resolve No Covariates         Cost of War  1
com, resolve, cov     0.49645902 0.97061239  0.51149051 0.60904679    com, resolve, cov    Covariates     Explicit threat  1
mob, resolve, cov     2.05989583 0.97866777  2.10479581 0.03539539    mob, resolve, cov    Covariates        Mobilization  1
his, resolve, cov    -0.18866582 0.82913953 -0.22754411 0.82001680    his, resolve, cov    Covariates Nationalist History  1
eli.f, resolve, cov  -0.32982632 1.59188027 -0.20719292 0.83587383  eli.f, resolve, cov    Covariates         Biding Time  1
eli.c, resolve, cov  -0.61570543 1.58970068 -0.38730903 0.69855602  eli.c, resolve, cov    Covariates         Cost of War  1
                                                  names4
com, approval            Explicit threat\n No Covariates
mob, approval               Mobilization\n No Covariates
his, approval        Nationalist History\n No Covariates
eli.f, approval              Biding Time\n No Covariates
eli.c, approval              Cost of War\n No Covariates
com, approval, cov          Explicit threat\n Covariates
mob, approval, cov             Mobilization\n Covariates
his, approval, cov      Nationalist History\n Covariates
eli.f, approval, cov            Biding Time\n Covariates
eli.c, approval, cov            Cost of War\n Covariates
com, resolve             Explicit threat\n No Covariates
mob, resolve                Mobilization\n No Covariates
his, resolve         Nationalist History\n No Covariates
eli.f, resolve               Biding Time\n No Covariates
eli.c, resolve               Cost of War\n No Covariates
com, resolve, cov           Explicit threat\n Covariates
mob, resolve, cov              Mobilization\n Covariates
his, resolve, cov       Nationalist History\n Covariates
eli.f, resolve, cov             Biding Time\n Covariates
eli.c, resolve, cov             Cost of War\n Covariates

> innerCI.n <- 1.64 #set so exclusion of CI implies two sided significance of 0.1

> outerCI.n <- 1.96 #set so exclusion of CI implies two sided significance of 0.05

> r <- !is.na(d$asc) & rb

> n <- length(d[r,1])

> type <- "Hyp"

> r2 <- statement.results$dv==0 & (statement.results$names3=="Explicit threat" | statement.results$names3=="Mobilization")   #& statement.results$names2=="No Covariates" 

> dv.n <- "Approval"

> title.w <- "Effect on"

> covs <- ""

> main.t <- "1StateA-"

> ymin.n <- -1; ymax.n <- .4

> source("./6-coef-figuresb.R", echo=TRUE)

> #6-coef-figuresb.r
> 
> 
> sign.n <- 1

> # if (dv.n == "Disapproval") {
> #   sign.n <- -1
> # }
> 
> hjust.n <- -0.2

> # if (dv.n == "Approval" & type=="Hyp") {
> #   hjust.n <- 0.15
> # }
> # if (dv.n == "Approval" & type=="Hist") {
> #   hjust.n <- 0.15
> # }
> 
>  .... [TRUNCATED] 

> pvalues.labels <- paste(rep("p=",length(pvalues)), pvalues, sep="")

> title.f <- paste(main.t, type, "-", dv.n, sep="")

> title.fig <- paste(title.w, " ", dv.n, ", ", type, sep="")

> if (covs!=""){
+   title.f <- paste(main.t, type, "-", dv.n, "-", covs, sep="")
+   title.fig <- paste(title.w, " ", dv.n, ", ", type, ", ", covs, s .... [TRUNCATED] 

> ggplot(statement.results[r2,]) +    
+   geom_linerange(aes(x = names4, ymin = sign.n * est - outerCI.n*se, ymax = sign.n * est + outerCI.n*se), lwd .... [TRUNCATED] 

> #", n=", n
> 
> 
> 
> p <- recordPlot()

> pdf(paste(fig.loc,title.f,".pdf", sep=""), width=9, height=3)

> p

> dev.off()
RStudioGD 
        2 

> pvalues <- -1

> type <- "Hyp"

> r2 <- statement.results$dv==0 & (statement.results$names3!="Explicit threat" & statement.results$names3!="Mobilization")   #& statement.results$names2=="No Covariates" 

> dv.n <- "Approval"

> title.w <- "Effect on"

> covs <- ""

> main.t <- "1StateB-"

> ymin.n <- -1; ymax.n <- .4

> source("./6-coef-figuresb.R", echo=TRUE)

> #6-coef-figuresb.r
> 
> 
> sign.n <- 1

> # if (dv.n == "Disapproval") {
> #   sign.n <- -1
> # }
> 
> hjust.n <- -0.2

> # if (dv.n == "Approval" & type=="Hyp") {
> #   hjust.n <- 0.15
> # }
> # if (dv.n == "Approval" & type=="Hist") {
> #   hjust.n <- 0.15
> # }
> 
>  .... [TRUNCATED] 

> pvalues.labels <- paste(rep("p=",length(pvalues)), pvalues, sep="")

> title.f <- paste(main.t, type, "-", dv.n, sep="")

> title.fig <- paste(title.w, " ", dv.n, ", ", type, sep="")

> if (covs!=""){
+   title.f <- paste(main.t, type, "-", dv.n, "-", covs, sep="")
+   title.fig <- paste(title.w, " ", dv.n, ", ", type, ", ", covs, s .... [TRUNCATED] 

> ggplot(statement.results[r2,]) +    
+   geom_linerange(aes(x = names4, ymin = sign.n * est - outerCI.n*se, ymax = sign.n * est + outerCI.n*se), lwd .... [TRUNCATED] 

> #", n=", n
> 
> 
> 
> p <- recordPlot()

> pdf(paste(fig.loc,title.f,".pdf", sep=""), width=9, height=3)

> p

> dev.off()
RStudioGD 
        2 

> pvalues <- -1

> type <- "Hyp"

> r2 <- statement.results$dv==0 & statement.results$names2=="No Covariates"

> dv.n <- "Approval"

> title.w <- "Effect on"

> covs <- ""

> main.t <- "1State-"

> ymin.n <- -1; ymax.n <- .4

> source("./6-coef-figuresb.R", echo=TRUE)

> #6-coef-figuresb.r
> 
> 
> sign.n <- 1

> # if (dv.n == "Disapproval") {
> #   sign.n <- -1
> # }
> 
> hjust.n <- -0.2

> # if (dv.n == "Approval" & type=="Hyp") {
> #   hjust.n <- 0.15
> # }
> # if (dv.n == "Approval" & type=="Hist") {
> #   hjust.n <- 0.15
> # }
> 
>  .... [TRUNCATED] 

> pvalues.labels <- paste(rep("p=",length(pvalues)), pvalues, sep="")

> title.f <- paste(main.t, type, "-", dv.n, sep="")

> title.fig <- paste(title.w, " ", dv.n, ", ", type, sep="")

> if (covs!=""){
+   title.f <- paste(main.t, type, "-", dv.n, "-", covs, sep="")
+   title.fig <- paste(title.w, " ", dv.n, ", ", type, ", ", covs, s .... [TRUNCATED] 

> ggplot(statement.results[r2,]) +    
+   geom_linerange(aes(x = names4, ymin = sign.n * est - outerCI.n*se, ymax = sign.n * est + outerCI.n*se), lwd .... [TRUNCATED] 

> #", n=", n
> 
> 
> 
> p <- recordPlot()

> pdf(paste(fig.loc,title.f,".pdf", sep=""), width=9, height=3)

> p

> dev.off()
RStudioGD 
        2 

> pvalues <- -1

> type <- "Hyp"

> r2 <- statement.results$dv==1 & statement.results$names2=="No Covariates"

> dv.n <- "Resolve"

> title.w <- "Effect on"

> covs <- ""

> main.t <- "1State-"

> ymin.n <- -1; ymax.n <- .4

> source("./6-coef-figuresb.R", echo=TRUE)

> #6-coef-figuresb.r
> 
> 
> sign.n <- 1

> # if (dv.n == "Disapproval") {
> #   sign.n <- -1
> # }
> 
> hjust.n <- -0.2

> # if (dv.n == "Approval" & type=="Hyp") {
> #   hjust.n <- 0.15
> # }
> # if (dv.n == "Approval" & type=="Hist") {
> #   hjust.n <- 0.15
> # }
> 
>  .... [TRUNCATED] 

> pvalues.labels <- paste(rep("p=",length(pvalues)), pvalues, sep="")

> title.f <- paste(main.t, type, "-", dv.n, sep="")

> title.fig <- paste(title.w, " ", dv.n, ", ", type, sep="")

> if (covs!=""){
+   title.f <- paste(main.t, type, "-", dv.n, "-", covs, sep="")
+   title.fig <- paste(title.w, " ", dv.n, ", ", type, ", ", covs, s .... [TRUNCATED] 

> ggplot(statement.results[r2,]) +    
+   geom_linerange(aes(x = names4, ymin = sign.n * est - outerCI.n*se, ymax = sign.n * est + outerCI.n*se), lwd .... [TRUNCATED] 

> #", n=", n
> 
> 
> 
> p <- recordPlot()

> pdf(paste(fig.loc,title.f,".pdf", sep=""), width=9, height=3)

> p

> dev.off()
RStudioGD 
        2 

> pvalues <- -1

> type <- "Hyp"

> r2 <- statement.results$dv==0 & statement.results$names2=="Covariates"

> dv.n <- "Approval"

> title.w <- "Effect on"

> covs <- "Covs"

> main.t <- "1State-"

> ymin.n <- -1; ymax.n <- .4

> source("./6-coef-figuresb.R", echo=TRUE)

> #6-coef-figuresb.r
> 
> 
> sign.n <- 1

> # if (dv.n == "Disapproval") {
> #   sign.n <- -1
> # }
> 
> hjust.n <- -0.2

> # if (dv.n == "Approval" & type=="Hyp") {
> #   hjust.n <- 0.15
> # }
> # if (dv.n == "Approval" & type=="Hist") {
> #   hjust.n <- 0.15
> # }
> 
>  .... [TRUNCATED] 

> pvalues.labels <- paste(rep("p=",length(pvalues)), pvalues, sep="")

> title.f <- paste(main.t, type, "-", dv.n, sep="")

> title.fig <- paste(title.w, " ", dv.n, ", ", type, sep="")

> if (covs!=""){
+   title.f <- paste(main.t, type, "-", dv.n, "-", covs, sep="")
+   title.fig <- paste(title.w, " ", dv.n, ", ", type, ", ", covs, s .... [TRUNCATED] 

> ggplot(statement.results[r2,]) +    
+   geom_linerange(aes(x = names4, ymin = sign.n * est - outerCI.n*se, ymax = sign.n * est + outerCI.n*se), lwd .... [TRUNCATED] 

> #", n=", n
> 
> 
> 
> p <- recordPlot()

> pdf(paste(fig.loc,title.f,".pdf", sep=""), width=9, height=3)

> p

> dev.off()
RStudioGD 
        2 

> pvalues <- -1

> type <- "Hyp"

> r2 <- statement.results$dv==1 & statement.results$names2=="Covariates"

> dv.n <- "Resolve"

> title.w <- "Effect on"

> covs <- "Covs"

> main.t <- "1State-"

> ymin.n <- -1; ymax.n <- .4

> source("./6-coef-figuresb.R", echo=TRUE)

> #6-coef-figuresb.r
> 
> 
> sign.n <- 1

> # if (dv.n == "Disapproval") {
> #   sign.n <- -1
> # }
> 
> hjust.n <- -0.2

> # if (dv.n == "Approval" & type=="Hyp") {
> #   hjust.n <- 0.15
> # }
> # if (dv.n == "Approval" & type=="Hist") {
> #   hjust.n <- 0.15
> # }
> 
>  .... [TRUNCATED] 

> pvalues.labels <- paste(rep("p=",length(pvalues)), pvalues, sep="")

> title.f <- paste(main.t, type, "-", dv.n, sep="")

> title.fig <- paste(title.w, " ", dv.n, ", ", type, sep="")

> if (covs!=""){
+   title.f <- paste(main.t, type, "-", dv.n, "-", covs, sep="")
+   title.fig <- paste(title.w, " ", dv.n, ", ", type, ", ", covs, s .... [TRUNCATED] 

> ggplot(statement.results[r2,]) +    
+   geom_linerange(aes(x = names4, ymin = sign.n * est - outerCI.n*se, ymax = sign.n * est + outerCI.n*se), lwd .... [TRUNCATED] 

> #", n=", n
> 
> 
> 
> p <- recordPlot()

> pdf(paste(fig.loc,title.f,".pdf", sep=""), width=9, height=3)

> p

> dev.off()
RStudioGD 
        2 

> pvalues <- -1

> type <- "Hyp"

> r2 <- pro.results$dv==0

> dv.n <- "Approval"

> title.w <- "Effect of Provocation on"

> main.t <- "1Prov-"

> ymin.n <- -1; ymax.n <- .4

> source("./6-coef-figures.R", echo=TRUE)

> #6-coef-figures.r
> title.f <- paste(main.t, type, "-", dv.n, sep="")

> sign.n <- 1

> hjust.n <- -0.2

> # if (dv.n == "Approval" & type=="Hyp") {
> #   hjust.n <- 0.15
> # }
> # if (dv.n == "Approval" & type=="Hist") {
> #   hjust.n <- 0.15
> # }
> 
>  .... [TRUNCATED] 

> #", n=", n
> 
> # +theme(axis.text=element_text(size=12),
> #        axis.title=element_text(size=14,face="bold"), plot.title = element_text(size =  .... [TRUNCATED] 

> pdf(paste(fig.loc,title.f,".pdf", sep=""), width=9, height=3)

> print(p)

> dev.off()
RStudioGD 
        2 

> r2 <- pro.results$dv==1

> dv.n <- "Resolve"

> title.w <- "Effect of Provocation on"

> ymin.n <- -1.5; ymax.n <- 3.2

> source("./6-coef-figures.R", echo=TRUE)

> #6-coef-figures.r
> title.f <- paste(main.t, type, "-", dv.n, sep="")

> sign.n <- 1

> hjust.n <- -0.2

> # if (dv.n == "Approval" & type=="Hyp") {
> #   hjust.n <- 0.15
> # }
> # if (dv.n == "Approval" & type=="Hist") {
> #   hjust.n <- 0.15
> # }
> 
>  .... [TRUNCATED] 

> #", n=", n
> 
> # +theme(axis.text=element_text(size=12),
> #        axis.title=element_text(size=14,face="bold"), plot.title = element_text(size =  .... [TRUNCATED] 

> pdf(paste(fig.loc,title.f,".pdf", sep=""), width=9, height=3)

> print(p)

> dev.off()
RStudioGD 
        2 

> #------------------------
> #which country?
> #----------------------
> 
> 
> #which country? 
> tab <- table(d$a.pcono)

> tab2 <- prop.table(tab)

> library(xtable)

> xtable(tab2, digits=3)
% latex table generated in R 3.5.2 by xtable 1.8-3 package
% Wed Feb 13 13:49:31 2019
\begin{table}[ht]
\centering
\begin{tabular}{rr}
  \hline
 & V1 \\ 
  \hline
 & 0.468 \\ 
  Afghanistan & 0.000 \\ 
  Cambodia & 0.000 \\ 
  Germany & 0.000 \\ 
  India & 0.039 \\ 
  Indonesia & 0.001 \\ 
  Japan & 0.311 \\ 
  Laos & 0.001 \\ 
  Malaysia & 0.001 \\ 
  Mongolia & 0.001 \\ 
  Myanmar & 0.003 \\ 
  Nepal & 0.001 \\ 
  North Korea & 0.014 \\ 
  Pakistan & 0.001 \\ 
  Philippines & 0.073 \\ 
  Russia & 0.017 \\ 
  South Korea & 0.006 \\ 
  Taiwan & 0.004 \\ 
  Thailand & 0.001 \\ 
  UK & 0.001 \\ 
  US & 0.006 \\ 
  Vietnam & 0.051 \\ 
   \hline
\end{tabular}
\end{table}

> #-----------------------------------------------------------------------
> #National Honour 
> #-------------------------------------------------------------------------
> 
> 
> rm(list = ls())

> setwd("~/Dropbox/Dafoe-Weiss-Empirics/18-04-12-ISQ-Raluca/Code/Replication File ISQ/")

> # Customized Stargazer Function, without asterisk inflation
> stargazerAD <- function(table, title="Default", filename="Figures/default.tex", dep.var.labels=NULL) {
+   a <- stargazer(table, title=title,  out=filename, 
+                  align=TRUE, star.cutoffs = c(0.1, 0.05, 0.01, 0.001), star.char = c("\\dagger", "*", "**", "***"), 
+                  notes="$^{\\dagger} p<0.1$; $^{*} p<0.05$; $^{**} p<0.01$; $^{***} p<0.001$", notes.append=FALSE, single.row=TRUE)
+   return(a)
+ }

> load("./MASTER CODE/hypanalysis.Rdata")

> #when prequestions asked?
> 
> #qplot(d$start.time,d$pre.questions, geom='smooth', span =0.9)  
> 
> ggplot(d,aes(x=start.time.n,y=pre.questions))+stat_smooth(se=F) + 
+   geom_vline(xintercept = d$start.time.n[1850])  

> df <- d[d$start.time.n<d$start.time.n[1850],]

> m <-lm(asc~pre.questions, data=df)

> stargazerAD(m, title="Prequestions Effect on Approval (Hypothetical Design)", file="../../Figures/hyp_preq.tex")

% Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu
% Date and time: Wed, Feb 13, 2019 - 13:49:32
% Requires LaTeX packages: dcolumn 
\begin{table}[!htbp] \centering 
  \caption{Prequestions Effect on Approval (Hypothetical Design)} 
  \label{} 
\begin{tabular}{@{\extracolsep{5pt}}lD{.}{.}{-3} } 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
 & \multicolumn{1}{c}{\textit{Dependent variable:}} \\ 
\cline{2-2} 
\\[-1.8ex] & \multicolumn{1}{c}{asc} \\ 
\hline \\[-1.8ex] 
 pre.questions & -0.097$ $(0.083) \\ 
  Constant & 3.005^{***}$ $(0.058) \\ 
 \hline \\[-1.8ex] 
Observations & \multicolumn{1}{c}{769} \\ 
R$^{2}$ & \multicolumn{1}{c}{0.002} \\ 
Adjusted R$^{2}$ & \multicolumn{1}{c}{0.001} \\ 
Residual Std. Error & \multicolumn{1}{c}{1.144 (df = 767)} \\ 
F Statistic & \multicolumn{1}{c}{1.389 (df = 1; 767)} \\ 
\hline 
\hline \\[-1.8ex] 
\textit{Note:}  & \multicolumn{1}{r}{$^{\dagger} p<0.1$; $^{*} p<0.05$; $^{**} p<0.01$; $^{***} p<0.001$} \\ 
\end{tabular} 
\end{table} 
 [1] ""                                                                                                                  
 [2] "% Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu"       
 [3] "% Date and time: Wed, Feb 13, 2019 - 13:49:32"                                                                     
 [4] "% Requires LaTeX packages: dcolumn "                                                                               
 [5] "\\begin{table}[!htbp] \\centering "                                                                                
 [6] "  \\caption{Prequestions Effect on Approval (Hypothetical Design)} "                                               
 [7] "  \\label{} "                                                                                                      
 [8] "\\begin{tabular}{@{\\extracolsep{5pt}}lD{.}{.}{-3} } "                                                             
 [9] "\\\\[-1.8ex]\\hline "                                                                                              
[10] "\\hline \\\\[-1.8ex] "                                                                                             
[11] " & \\multicolumn{1}{c}{\\textit{Dependent variable:}} \\\\ "                                                       
[12] "\\cline{2-2} "                                                                                                     
[13] "\\\\[-1.8ex] & \\multicolumn{1}{c}{asc} \\\\ "                                                                     
[14] "\\hline \\\\[-1.8ex] "                                                                                             
[15] " pre.questions & -0.097$ $(0.083) \\\\ "                                                                           
[16] "  Constant & 3.005^{***}$ $(0.058) \\\\ "                                                                          
[17] " \\hline \\\\[-1.8ex] "                                                                                            
[18] "Observations & \\multicolumn{1}{c}{769} \\\\ "                                                                     
[19] "R$^{2}$ & \\multicolumn{1}{c}{0.002} \\\\ "                                                                        
[20] "Adjusted R$^{2}$ & \\multicolumn{1}{c}{0.001} \\\\ "                                                               
[21] "Residual Std. Error & \\multicolumn{1}{c}{1.144 (df = 767)} \\\\ "                                                 
[22] "F Statistic & \\multicolumn{1}{c}{1.389 (df = 1; 767)} \\\\ "                                                      
[23] "\\hline "                                                                                                          
[24] "\\hline \\\\[-1.8ex] "                                                                                             
[25] "\\textit{Note:}  & \\multicolumn{1}{r}{$^{\\dagger} p<0.1$; $^{*} p<0.05$; $^{**} p<0.01$; $^{***} p<0.001$} \\\\ "
[26] "\\end{tabular} "                                                                                                   
[27] "\\end{table} "                                                                                                     

> #-----------------------------------------------------------------------
> #Raw Results
> #-------------------------------------------------------------------------
> 
> rm(list = ls())

> library(ggplot2)

> library(coefplot)

> library(stargazer)

> library(scales)

> library(tidyverse)

> setwd("~/Dropbox/Dafoe-Weiss-Empirics/18-04-12-ISQ-Raluca/Code/Replication File ISQ/")

> load("./MASTER CODE/hyp.Rdata")

> myvars <- names(d) %in% c("his", "pro", "prot", "com", "mob", "eli.f", "eli.c", "asc") 

> small_data <- d[myvars]

> small_data$ID <- seq.int(nrow(small_data))

> #Constructing Appropriate Comparisons 
> #Treatments are assigned independently, except only one of biding time or cost of war can occur 
> 
> # the control is those without biding time and those without cost of war (only one can happen)
> small_data$new_eli.f[small_data$eli.f==1] <- 1

> small_data$new_eli.f[small_data$eli.f==0 & small_data$eli.c==0] <- 0

> #similarly for cost of war
> 
> small_data$new_eli.c[small_data$eli.c==1] <- 1

> small_data$new_eli.c[small_data$eli.c==0 & small_data$eli.f==0] <- 0

> #making a dataset for each treatment 
> 
> #history
> histvars <- names(small_data) %in% c("his", "asc")

> hist_data <- small_data[histvars]

> hist_data$his_type[small_data$his==1] <- "Treatment"

> hist_data$his_type[small_data$his==0] <- "Control"

> sum(is.na(hist_data$his_type)) ## no missing for history treatment
[1] 0

> sum(is.na(hist_data$asc)) ## some missing for asc. we'll take them out for the ggplot
[1] 249

> hist_data <- na.omit(hist_data) ##taking out missing values 

> hist_data2 <- hist_data %>% 
+   group_by(his,asc) %>% 
+   summarise(count=n()) %>% 
+   mutate(perc=count/sum(count))

> hist_data2$overall = "History"

> hist_gg <-ggplot(hist_data2, aes(x=as.factor(asc), y=perc, group=as.factor(his), fill=as.factor(his)))

> hist_gg2 <- hist_gg +
+   geom_bar(stat= "identity", position="dodge") + 
+   scale_y_continuous(labels=percent) + 
+   facet_wrap(~overall)

> hist_gg3 <- hist_gg2 +  
+   ylab("Percentage") + 
+   xlab (" ")  + 
+   theme_bw() + 
+   theme(axis.text.x = element_text(angle = 45, hjust = 1))   + 
+   scale_x_discrete(breaks=c(1,2,3,4,5),labels= c("S Disaprove", "Disaprove", "Neither", "Approve", "S Approve")) + 
+   scale_fill_manual(labels=c("Control", "Treatment"), values=c("goldenrod1", "grey40"), name = "Treatment Status") + 
+   coord_cartesian(ylim = c(0,.5))

> #Commitment
> 
> comvars <- names(small_data) %in% c("com", "asc")

> com_data <- small_data[comvars]

> com_data$com_type[small_data$com==1] <- "Treatment"

> com_data$com_type[small_data$com==0] <- "Control"

> sum(is.na(com_data$com_type)) ## no missing 
[1] 0

> sum(is.na(com_data$asc)) ## some missing for asc. we'll take them out for the ggplot
[1] 249

> com_data <- na.omit(com_data) ##taking out missing values 

> com_data2 <- com_data %>% 
+   group_by(com,asc) %>% 
+   summarise(count=n()) %>% 
+   mutate(perc=count/sum(count))

> com_data2$overall = "Commitment"

> com_gg <-ggplot(com_data2, aes(x=as.factor(asc), y=perc, group=as.factor(com), fill=as.factor(com)))

> com_gg2 <- com_gg +
+   geom_bar(stat="identity", position="dodge") + 
+   scale_y_continuous(labels=percent) + 
+   facet_wrap(~overall)

> com_gg3 <- com_gg2 +  
+   ylab(" ") + 
+   xlab (" ")  + 
+   theme_bw() + 
+   theme(axis.text.x = element_text(angle = 45, hjust = 1))   + 
+   scale_x_discrete(breaks=c(1,2,3,4,5),labels= c("S Disaprove", "Disaprove", "Neither", "Approve", "S Approve")) + 
+   scale_fill_manual(labels=c("Control", "Treatment"), values=c("goldenrod1", "grey40"), name = "Treatment Status") + 
+   coord_cartesian(ylim = c(0,.5))

> #Mobilization
> 
> mobvars <- names(small_data) %in% c("mob", "asc")

> mob_data <- small_data[mobvars]

> mob_data$mob_type[small_data$mob==1] <- "Treatment"

> mob_data$mob_type[small_data$mob==0] <- "Control"

> sum(is.na(mob_data$mob_type)) ## no missing 
[1] 0

> sum(is.na(mob_data$asc)) ## some missing for asc. we'll take them out for the ggplot
[1] 249

> mob_data <- na.omit(mob_data) ##taking out missing values 

> mob_data2 <- mob_data %>% 
+   group_by(mob,asc) %>% 
+   summarise(count=n()) %>% 
+   mutate(perc=count/sum(count))

> mob_data2$overall = "Mobilization"

> mob_gg <-ggplot(mob_data2, aes(x=as.factor(asc), y=perc, group=as.factor(mob), fill=as.factor(mob)))

> mob_gg2 <- mob_gg +
+   geom_bar(stat="identity", position="dodge") + 
+   scale_y_continuous(labels=percent) + 
+   facet_wrap(~overall)

> mob_gg3 <- mob_gg2 +  
+   ylab(" ") + 
+   xlab (" ")  + 
+   theme_bw() + 
+   theme(axis.text.x = element_text(angle = 45, hjust = 1))   + 
+   scale_x_discrete(breaks=c(1,2,3,4,5),labels= c("S Disaprove", "Disaprove", "Neither", "Approve", "S Approve")) + 
+   scale_fill_manual(labels=c("Control", "Treatment"), values=c("goldenrod1", "grey40"), name = "Treatment Status") + 
+   coord_cartesian(ylim = c(0,.5))

> #Biding Time (eli.f)
> 
> elifvars <- names(small_data) %in% c("new_eli.f", "asc")

> elif_data <- small_data[elifvars]

> elif_data$elif_type[small_data$new_eli.f==1] <- "Treatment"

> elif_data$elif_type[small_data$new_eli.f==0] <- "Control"

> sum(is.na(elif_data$elif_type)) ## no missing 
[1] 222

> sum(is.na(elif_data$asc)) ## some missing for asc. we'll take them out for the ggplot
[1] 249

> elif_data <- na.omit(elif_data) ##taking out missing values 

> elif_data2 <- elif_data %>% 
+   group_by(new_eli.f,asc) %>% 
+   summarise(count=n()) %>% 
+   mutate(perc=count/sum(count))

> elif_data2$overall = "Biding Time"

> elif_gg <-ggplot(elif_data2, aes(x=as.factor(asc), y=perc, group=as.factor(new_eli.f), fill=as.factor(new_eli.f)))

> elif_gg2 <- elif_gg +
+   geom_bar(stat="identity", position="dodge") + 
+   scale_y_continuous(labels=percent) + 
+   facet_wrap(~overall)

> elif_gg3 <- elif_gg2 +  
+   ylab("Percentage") + 
+   xlab (" ")  + 
+   theme_bw() + 
+   theme(axis.text.x = element_text(angle = 45, hjust = 1))   + 
+   scale_x_discrete(breaks=c(1,2,3,4,5),labels= c("S Disaprove", "Disaprove", "Neither", "Approve", "S Approve")) + 
+   scale_fill_manual(labels=c("Control", "Treatment"), values=c("goldenrod1", "grey40"), name = "Treatment Status") + 
+   coord_cartesian(ylim = c(0,.5))

> #Cost of war (eli.c)
> 
> elicvars <- names(small_data) %in% c("new_eli.c", "asc")

> elic_data <- small_data[elicvars]

> elic_data$elic_type[small_data$new_eli.c==1] <- "Treatment"

> elic_data$elic_type[small_data$new_eli.c==0] <- "Control"

> sum(is.na(elic_data$elic_type)) ## no missing 
[1] 223

> sum(is.na(elic_data$asc)) ## some missing for asc. we'll take them out for the ggplot
[1] 249

> elic_data <- na.omit(elic_data) ##taking out missing values 

> elic_data2 <- elic_data %>% 
+   group_by(new_eli.c,asc) %>% 
+   summarise(count=n()) %>% 
+   mutate(perc=count/sum(count))

> elic_data2$overall = "Cost of War"

> elic_gg <-ggplot(elic_data2, aes(x=as.factor(asc), y=perc, group=as.factor(new_eli.c), fill=as.factor(new_eli.c)))

> elic_gg2 <- elic_gg +
+   geom_bar(stat="identity", position="dodge") + 
+   scale_y_continuous(labels=percent) + 
+   facet_wrap(~overall)

> elic_gg3 <- elic_gg2 +  
+   ylab(" ") + 
+   xlab ("Government Approval")  + 
+   theme_bw() + 
+   theme(axis.text.x = element_text(angle = 45, hjust = 1))   + 
+   scale_x_discrete(breaks=c(1,2,3,4,5),labels= c("S Disaprove", "Disaprove", "Neither", "Approve", "S Approve")) + 
+   scale_fill_manual(labels=c("Control", "Treatment"), values=c("goldenrod1", "grey40"), name = "Treatment Status") + 
+   coord_cartesian(ylim = c(0,.5))

> #putting them together
> 
> library(ggpubr)

> ggarrange(hist_gg3, com_gg3, mob_gg3, elif_gg3, elic_gg3, 
+           ncol = 3, nrow = 2,common.legend = TRUE, legend = "right", align = "v")

> ggsave(file="../../Figures/hyp_vertical_only5.eps")

> #--------------------------------------------------------------------------------------- 
> #Coefficients Plot from Regression
> 
> #Regression Plot
> 
> treat1 <- lm(asc~his, data=hist_data)

> treat4 <- lm(asc~com, data=com_data)

> treat5 <- lm(asc~mob, data=mob_data)

> treat6 <- lm(asc~new_eli.c, data=elic_data)

> treat7 <- lm(asc~new_eli.f, data=elif_data)

> mlplot <- multiplot(treat1,  treat4, treat5, treat6, treat7,
+                     predictors = c("his",  "com", "mob", "new_eli.c","new_eli.f"), title="Effect on Approval, Hyp", xlab="Change in Approval")

> mlplot + theme_bw() + 
+   scale_y_discrete(label=c("History", "Commitment", 
+                            "Mobilization", "Cost of War", "Biding Time")) + 
+   theme(legend.position="none") + 
+   scale_color_manual(values=c("black", "black", "black", "black", "black", "black", "black"))

> ggsave(file="../../Figures/hyp_raw_coefplot_only5.eps")

> #Error Bar Plot
> 
> #History
> 
> gg1 <- ggplot(hist_data, aes(as.factor(his_type), asc, fill=as.factor(his_type)))+ 
+   stat_summary(fun.y=mean, geom="bar", width=1, position= "dodge") +
+   stat_summary(fun.data =mean_se, geom="errorbar",  width=.2, size=1, color="black",
+                position=position_dodge(width = .7)) +
+   ylab(" ") +   xlab("History") + 
+   scale_fill_manual(labels=c("Control", "Treatment"), values=c("goldenrod1", "grey40"), name="Treatment Status") + 
+   coord_cartesian(ylim=c(2.7,3.2)) + 
+   theme(panel.background = element_blank(), 
+         axis.line.y = element_line(colour = "Black", linetype = "solid"),
+         axis.ticks.length=unit(0.3,"cm"),
+         axis.ticks.x = element_blank(),
+         axis.text.x = element_blank(), 
+         axis.line.x = element_blank()) +
+   scale_y_continuous(limits = c(2.7,3.2),  expand = c(0,0), oob=rescale_none) 

> #Commitment
> 
> gg4 <- ggplot(com_data, aes(as.factor(com_type), asc, fill=as.factor(com_type)))+ 
+   stat_summary(fun.y=mean, geom="bar", width=1, position= "dodge") +
+   stat_summary(fun.data =mean_se, geom="errorbar",  width=.2, size=1, color="black",
+                position=position_dodge(width = .7)) +
+   ylab(" ") +   xlab("Commit") + 
+   scale_fill_manual(labels=c("Control", "Treatment"), values=c("goldenrod1", "grey40"), name="Treatment Status") + 
+   scale_y_continuous(limits = c(2.7,3.2),  expand = c(0,0), oob=rescale_none)  + 
+   coord_cartesian(ylim=c(2.7,3.2)) + 
+   theme(panel.background = element_blank(), 
+         axis.line.y = element_blank(),
+         axis.ticks.length=unit(0.3,"cm"),
+         axis.ticks.x = element_blank(),
+         axis.text.x = element_blank(), 
+         axis.ticks.y =element_blank(), 
+         axis.text.y = element_blank(),
+         axis.line.x = element_blank())

> #Mobilization
> 
> gg5 <- ggplot(mob_data, aes(as.factor(mob_type), asc, fill=as.factor(mob_type)))+ 
+   stat_summary(fun.y=mean, geom="bar", width=1, position= "dodge") +
+   stat_summary(fun.data =mean_se, geom="errorbar",  width=.2, size=1, color="black",
+                position=position_dodge(width = .7)) +
+   ylab(" ") +   xlab("Mobilize") + 
+   scale_fill_manual(labels=c("Control", "Treatment"), values=c("goldenrod1", "grey40"), name="Treatment Status") + 
+   scale_y_continuous(limits = c(2.7,3.2),  expand = c(0,0), oob=rescale_none)  + 
+   coord_cartesian(ylim=c(2.7,3.2)) + 
+   theme(panel.background = element_blank(), 
+         axis.line.y = element_blank(),
+         axis.ticks.length=unit(0.3,"cm"),
+         axis.ticks.x = element_blank(),
+         axis.text.x = element_blank(), 
+         axis.ticks.y =element_blank(), 
+         axis.text.y = element_blank(),
+         axis.line.x = element_blank())

> #Biding Time
> 
> gg6 <- ggplot(elif_data, aes(as.factor(elif_type), asc, fill=as.factor(elif_type)))+ 
+   stat_summary(fun.y=mean, geom="bar", width=1, position= "dodge") +
+   stat_summary(fun.data =mean_se, geom="errorbar",  width=.2, size=1, color="black",
+                position=position_dodge(width = .7)) +
+   ylab(" ") +   xlab("Biding") + 
+   scale_fill_manual(labels=c("Control", "Treatment"), values=c("goldenrod1", "grey40"), name="Treatment Status") + 
+   scale_y_continuous(limits = c(2.7,3.2),  expand = c(0,0), oob=rescale_none)  + 
+   coord_cartesian(ylim=c(2.7,3.2)) + 
+   theme(panel.background = element_blank(), 
+         axis.line.y = element_blank(),
+         axis.ticks.length=unit(0.3,"cm"),
+         axis.ticks.x = element_blank(),
+         axis.text.x = element_blank(), 
+         axis.ticks.y =element_blank(), 
+         axis.text.y = element_blank(),
+         axis.line.x = element_blank())

> #Cost of War 
> 
> gg7 <- ggplot(elic_data, aes(as.factor(elic_type), asc, fill=as.factor(elic_type)))+ 
+   stat_summary(fun.y=mean, geom="bar", width=1, position= "dodge") +
+   stat_summary(fun.data =mean_se, geom="errorbar",  width=.2, size=1, color="black",
+                position=position_dodge(width = .7)) +
+   ylab(" ") +   xlab("Cost of War") + 
+   scale_fill_manual(labels=c("Control", "Treatment"), values=c("goldenrod1", "grey40"), name="Treatment Status") + 
+   scale_y_continuous(limits = c(2.7,3.2),  expand = c(0,0), oob=rescale_none)  + 
+   coord_cartesian(ylim=c(2.7,3.2)) + 
+   theme(panel.background = element_blank(), 
+         axis.line.y = element_blank(),
+         axis.ticks.length=unit(0.3,"cm"),
+         axis.ticks.x = element_blank(),
+         axis.text.x = element_blank(), 
+         axis.ticks.y =element_blank(), 
+         axis.text.y = element_blank(),
+         axis.line.x = element_blank())

> ggarrange(gg1, gg4, gg5, gg6, gg7,
+           ncol = 5, nrow = 1,common.legend = TRUE, legend = "right")

> ggsave(file="../../Figures/hyp_subst_only5.eps")

> #End.
